开发者

jQuery UI Datepicker detect select

开发者 https://www.devze.com 2023-01-07 10:30 出处:网络
When a date is selected开发者_JS百科 by the user, I want to check a condition and cancel the selection

When a date is selected开发者_JS百科 by the user, I want to check a condition and cancel the selection

onSelect: function(dateText) {
       // code to cancel selection

}

How do i cancel it?


Use the beforeShowDay event.

So:

$(/*...*/).datepicker({
    beforeShowDay: function(date) {
        if(disableCondition)
            return [true,'','You can\'t select this!'];
        else
            return [false,'',''];
    }
});
0

精彩评论

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