Can the jQuery UI Datepicker be made to disable Saturdays and Sundays (and holidays)?

前端 未结 11 841
無奈伤痛
無奈伤痛 2020-11-22 04:02

I use a datepicker for choosing an appointment day. I already set the date range to be only for the next month. That works fine. I want to exclude Saturdays and Sundays f

11条回答
  •  野的像风
    2020-11-22 04:35

    $("#selector").datepicker({ beforeShowDay: highlightDays });
    
    ...
    
    var dates = [new Date("1/1/2011"), new Date("1/2/2011")];
    
    function highlightDays(date) {
    
        for (var i = 0; i < dates.length; i++) {
            if (date - dates[i] == 0) {
                return [true,'', 'TOOLTIP'];
            }
        }
        return [false];
    
    }
    

提交回复
热议问题