jQuery UI datepicker maxdate

99封情书 提交于 2019-12-06 13:09:20

Something like this should work for you:

function getMaxDate() {
    // Maximum date is today by default.
    var maxDate = new Date();

    // Is today Thursday or greater (Thurs. - Sat.)
    if (maxDate.getDay() >= 4) {
        // Yes? Make the date today's date plus the difference between today and
        // next Sunday
        maxDate.setDate(
            maxDate.getDate() + (7 - maxDate.getDay()));
    }
    return maxDate;
}

$('#startdate').datepicker({
    maxDate: getMaxDate(),
    beforeShowDay: disableSpecificWeekDays
});

Example: http://jsfiddle.net/RxQB4/

Basically, write a function that encapsulates your logic. When initializing the datepicker, call that function to retrieve the maximum date.

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