I have create to fields in my form and I have place in, two text fields for date range. I have run normaly my jQuery to assign on them the datepicker and work fine.
The text fields are auto filled with the current date in case the user fill out the form for first time, or with the saved data in case the user editing that form for second time.
Anyway, What I like to do is to auto set the minDate for the second field before I use the first.
This is my code:
$('#stigma_start').datepicker(
{
dateFormat: 'd MM yy',
timeFormat: 'h:mm',
hideIfNoPrevNext: false,
showWeek: true,
changeMonth: true,
changeYear: true,
onSelect: function(selectedDate)
{
var instance = $(this).data("datepicker");
var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
$('#stigma_expires').datepicker("option", "minDate", date);
}
}
);
$('#stigma_expires').datepicker(
{
dateFormat: 'd MM yy',
timeFormat: 'h:mm',
hideIfNoPrevNext: false,
showWeek: true,
changeMonth: true,
changeYear: true
}
);
How about setting minDate option explicitly for the second datepicker? The onSelect of the first one should set it correctly in this settup as well.