I have two date pickers. A startdate and an enddate.
The way I have the code set up is that the second datepicker won’t be initiated until the first one has been changed. The enddate datepicker is initialized with the current date on startdate. The only problem is that if you change the time on the first datepicker it doesn’t refresh the mindate on enddate.
$(function(){
$( "#startdate" ).datepicker({ minDate: currentTime });
//When the startdate changes change the mindate for the enddate picker
$( "#startdate" ).change(function (){
startTime = ($("#startdate").val());
$("#enddate").datepicker({ minDate: startTime });
});
//$( "#enddate" ).datepicker({ minDate: currentTime });
});
You will need to use the
optionmethod as described in the documentation (http://jqueryui.com/demos/datepicker/#method-option) to update theminDateoption of an already initialized widget:Notice I put a
varstatement in-front of thestartTimevariable so it will be declared in the local scope of the event handler. Also both Datepickers get initialized strait-off and then the#enddatewidget gets an updatedminDateoption each time the#startdateelement is changed.Here is a demo: http://jsfiddle.net/VP25m/