How to set the opening date of a jQuery datepicker, as well as the start and end date. I tried this but the calendar still opens to July (today) and the dates outside the min
and max
are not greyed out?
$('#datepicker').datepicker({
minDate: new Date('30/11/2014'),
maxDate: new Date('03/05/2015'),
setDate: new Date('30/11/2014')
});
See jsFiddle
You are creating your date objects incorrectly. The javascript date object parameters are Year, Month, Day. However, the month parameter is zero indexed so make sure you subtract one. For more information, please check the Date object reference.
$('#datepicker').datepicker({
minDate: new Date(2014, 10, 30),
maxDate: new Date(2015, 2, 5),
setDate: new Date(2014, 10, 30)
});
Live Demo
As Pluto has also mentioned, you can also format it in MM/DD/YYYY.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With