禁用Jquery日期选择器中的假期列表

时间:2010-05-27 14:10:51

标签: jquery

如何使用jquery日期选择器禁用假期列表?

1 个答案:

答案 0 :(得分:1)

var disabledDates = ['08/30/2010', '05/30/2010', '02/14/2011']; 

function noWeekendsOrHolidays(date) { 
        var noWeekend = $.datepicker.noWeekends(date); 
        if (noWeekend[0]) { 
            return disableDays(date); 
        } else { 
            return noWeekend; 
        } 
} 

function disableDays(date) { 
    for (var i = 0; i < disabledDates.length; i++) { 
        if (new Date(disabledDates[i]).toString() == date.toString()) {              
            return [false]; 
        } 
    } 
    return [true]; 
}  

$(.selector).datepicker({minDate: new Date(),beforeShowDay: noWeekendsOrHolidays, changeYear: true ,changeMonth: true});