我想禁用整个星期天

I want to disable all Sunday

function () {
    // initialize date picker with correct date format
    Calendar.setup({
        inputField: 'delivery_date',
        ifFormat: '%Y-%m-%d',
        align: 'Bl',
        button: 'delivery_date',

        singleClick: true,
        disableFunc : function(date) {
            var today = new Date();
            today.setDate(today.getDate() + 4);
            date = date < today;
            return (date);
        }         
    });
}

以上代码用于禁用当前数据五天后的日期。 我也想禁用所有星期日

我该怎么做。

我会选择这个:

disableFunc : function(date) {
    var today = new Date();
    today.setDate(today.getDate() + 4);
    return date < today || date.getDay() == 0;
}

这里你要仔细检查一下,所以要禁用所有提前 4 天以上的日期以及所有在星期日到来的日期。

另请参阅:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay

The value returned by getDay() is an integer corresponding to the day of the week: 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on.

$("#datepicker").datepicker({
    beforeShowDay: function(date) {
        var day = date.getDay();
        return [(day != 0), ''];
    }
});

参考:Disable all Sundays in jQuery UI Calendar