jQuery Datepicker - Programatically Limit Second Datepicker
Posted
by Dodinas
on Stack Overflow
See other posts from Stack Overflow
or by Dodinas
Published on 2010-04-03T18:45:01Z
Indexed on
2010/04/03
18:53 UTC
Read the original article
Hit count: 639
Hello all,
I've recently been using the following piece of code to limit my 2nd Date picker (end date) so that it does not precede the date of the 1st Date picker.
$("#datepicker").datepicker({
minDate: +5,
maxDate: '+1M +10D',
onSelect: function(dateText, inst){
var the_date = dateText;
$("#datepicker2").datepicker('option', 'minDate', the_date);
}
});
$("#datepicker2").datepicker({
maxDate: '+1M +10D',
onSelect: function(dateText, inst){
}
});
However, lately, I wanted to format my datepickers using:
dateFormat: 'yy-mm-dd'
But now, the 2nd datepicker actually allows the user to pick a date 1 day before.
For example, if the user picks the 1st date: 2010-04-03, when the 2nd Datepicker pops up, they are able to pick 2010-04-02 (1 day before their first selected date).
I do not want the user to be able to pick a date that was before their first selected day.
Any ideas why this isn't working after I added in the "dateFormat"?
© Stack Overflow or respective owner