Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts

    Question validating - Duplicate ID datepicker

    Hi,

    I am going through my code validating, see here: http://validator.w3.org/check?uri=ht...alidator%2F1.1

    I have 1 error left to fix, I have a dupicate ID="datepicker"
    I need this in here as it runs from a JavaScript, is there anyway I can get this validated?

    here is my code with the relevant JavaScript

    Code:
    <script type="text/javascript">
    $( "#datepicker" ).datepicker({
    			changeMonth: true,
    			changeYear: true,
    			yearRange: '1920:1994'
    		});
    </script>
    
    <span id="sprytextfield6">
    									<input name="rsAge" type="text" class="textbox" id="datepicker" />
    									<span class="textfieldRequiredMsg">A value is required.</span></span>
    									<!-- Datepicker -->
    									<span id="datepicker"></span>

  • #2
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,957
    Thanks
    9
    Thanked 727 Times in 721 Posts
    You need the id in for the datepicker, yes, but you don't want it on two different elements. It would be normal to have it on the input, assuming this is UI Datepicker. Are you using the id on the span as well - or can that be removed?

  • #3
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts
    hi

    the <span id="datepicker"></span> part is the bit that shows the JQuery UI DatePicker when you focus on the input field, so no, it can't be removed.

    Any other ideas? thanks anyway SB65

  • #4
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,957
    Thanks
    9
    Thanked 727 Times in 721 Posts
    The datepicker will run on the focus event of the the element #datepicker. You have this on your input tag - you shouldn't need it on a span as well. If you really really need the span, for some other reason, make the id a class instead.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •