Hello,
i am using this code found in this forum :
$('#startsession').datepicker({
minDate : 0,
maxDate : '+1D',
firstDay : 0,
dateFormat: 'yy-mm-dd',
buttonImage: '../datepicker/calendar.gif',
showOn: 'both',
onSelect: function(date) {
var daystart = $("#startsession").datepicker("getDate");
daystart.setDate(daystart.getDate());
$("#endsession").datepicker("option","minDate",daystart).datepicker("setdate", daystart).val(date);
}
});
$('#endsession').datepicker({
minDate : 0,
maxDate : '+1D',
firstDay : 0,
dateFormat: 'yy-mm-dd',
buttonImage: '../datepicker/calendar.gif',
showOn: 'both'
});
If today is 2010-02-09, when i choose a date (session beginning. ex.: 2010-02-18) in the first datepicker then i can't choose the same day (2010-02-18) or the following day (2010-02-19) in the second datepicker (session ending). I could change the maxDate in the init of the two datepickers to a number of days high enough to solve all possibilities but it permits to choose a date after the real end of a session.
Ex. : a user choose 2010-02-18 in the first datepicker then i would like that he can only choose a date between 2010-02-18 and 2010-02-19 for a session of one or two days.
In the future the number of session days will be between 1 and 105 then the max number of days will be set by a variable.
I tried to set a maxDate after the date is selected in the first datepicker like the way i set minDate but it did not work.
I calculate the date of the session end, put it in a variable endmaxdays and tried to set maxDate this way :
$("#endsession").datepicker("option","maxDate", endmaxdays);
It did not work.
i also tried to set maxDate with a value :
$("#endsession").datepicker("option","maxDate", "2010-02-19");
I tried many other ways, none worked.
So i think that i am doing a basic mistake.
Help will be appreciated.
Thanks