-2

我在这里更新了我的代码。我已经将范围放在了我需要在 datepicker 中的 beforeShowDays 中引用以禁用那些日子的 availableDays 函数中。

function unavailableDays(date) {

function createDateRange(first, last) {
var date = [];

for(var j = first; j < last; j.setDate(j.getDate() + 7))
dates.push(new Date(j.getTime()));

return date;
}

var disabledDays = createDateRange(new Date("1978-08-10"), new Date("1978-11-05"));

//date array to be disabled
var disabledDays = ["1963-3-10", "1963-3-17", "1963-3-24", "1963-3-31", "1965-9-18"];

var yy = date.getFullYear(), mm = date.getMonth(), dd = date.getDate();
for (i = 0; i < disabledDays.length; i++) {
if($.inArray(yy + '-' + (mm+1) + '-' + dd,disabledDays) != -1 || new Date() < date) {
return [false];
} }
return [true]; }
4

1 回答 1

0
function createDateRange(first, last) {
    var dates = [];

    for(var i = first; i < last; i.setDate(i.getDate() + 7))
        dates.push(new Date(i.getTime()));

    return dates;
}

var disabledDays = createDateRange(new Date("1978-08-10"), new Date("1978-11-05"));

样本

于 2012-04-05T18:58:08.947 回答