How to constrain min and max dates for jQuery-ui datepicker based on another date

纵然是瞬间 提交于 2019-12-01 01:56:09

Have a look at this demo. I've added some lines in the onSelect event like so:

    onSelect: function(dateStr) {
        var d1 = $(this).datepicker("getDate");
        d1.setDate(d1.getDate() + 0); // change to + 1 if necessary
        var d2 = $(this).datepicker("getDate");
        d2.setDate(d2.getDate() + 30); // change to + 29 if necessary
        $("#to").datepicker("setDate", null);
        $("#to").datepicker("option", "minDate", d1);
        $("#to").datepicker("option", "maxDate", d2);
        datepicked();
    }

According to my understanding of lodging business, the dates should be inclusive -- i.e. June/15/2012 + 30 nights should be June/14/2012. But I've followed the example you mentioned in the first few lines of question.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!