开发者

change the enddate choice with jquery datepicker

开发者 https://www.devze.com 2023-01-15 15:08 出处:网络
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

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号