Reputation: 57
Calendar shows Nov 1866 on open , but after choosing day it sets to current date (year) instead of 1866.
Here is example jsfiddle
$('#thedate').datepicker({
dateFormat: "dd-mm-yy",
changeYear: true,
changeMonth: true,
yearRange: "-150:-18",
autoSize: true,
});
Upvotes: 1
Views: 342
Reputation: 57
Thank you @hairmot for pointing that there is defaultDate property, I forgot about it.
Here is jsfiddle
Correct code :
$('#thedate').datepicker({
dateFormat: "dd-mm-yy",
changeYear: true,
changeMonth: true,
yearRange: "-150:-18",
defaultDate: "-150y",
autoSize: true,
});
Upvotes: 1
Reputation: 2975
The widget doens't appear to be setting the select year until an event is fired within it. The easy way to get around this is to set a defaultDate
defaultDate: '01-01-1866'
This wont populate the input on page load, but will make sure the values are processed immediately and your selected year is set.
Upvotes: 2