0

I have a form with multiple JQuery datepicker fields, but the problem is the first 2 fields only work and the rest not , i searched and found this , but didn't help., here is my code :

$('.datePicker').datepicker({
changeYear: true,
changeMonth: true,
autoSize: true,
dateFormat: "dd-mm-yy",
maxDate: "0y",
showAnim: "show",
yearRange:'c-70:c+0',

});

HTML:

<input type="text" class='datePicker' name='startDate' ><span><img alt="" src="${assetPath(src: 'calendar-icon.png')}"/></span>
<input type="text" class='datePicker' name='endDate' ><span><img alt="" src="${assetPath(src: 'calendar-icon.png')}"/></span>
5
  • As long as they all have the class .datePicker it should work. There's no need for a loop as the plugin does that internally anyway. Commented Apr 25, 2016 at 14:22
  • @adeneo , this what suppose to happen but i don't know what is wrong Commented Apr 25, 2016 at 14:27
  • You've only posted two fields, that seem to work just fine, what does the other fields look like ? Commented Apr 25, 2016 at 14:45
  • @adeneo, these 2 fields are duplicated 4 times . these are all the fields related to the datepicker Commented Apr 25, 2016 at 17:56
  • That still seems to work just fine, so something else must be wrong ? Commented Apr 25, 2016 at 18:10

1 Answer 1

0

Try this:

$('.datePicker').each(function(){
    $(this).datepicker({
    changeYear: true,
    changeMonth: true,
    autoSize: true,
    dateFormat: "dd-mm-yy",
    maxDate: "0y",
    showAnim: "show",
    yearRange:'c-70:c+0',
    });
});
Sign up to request clarification or add additional context in comments.

1 Comment

didn't help , still the same issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.