views:

9

answers:

1

Hi,

I have 2 textboxes: StartDate and endDate How can I make so the user will be able to pick from the endDate only the dates starting from the startDate text box and ending 24 hours after the startDate?

I tried this but it didnt work:

$("#startDate").change(function() {
    test = $(this).datepicker('getDate');

    $("#endDate").datepicker("option", "minDate", test); 

}); 

Thanks in advance!

Greg

A: 

You can set the minDate to 1 day later than the chosen #startDate like this:

$("#startDate").change(function() {
  var test = $(this).datepicker('getDate');
  test.setDate(test.getDate() + 1);
  $("#endDate").datepicker("option", "minDate", test); 
}); ​

You can test it out here.

Nick Craver