这是我下面的代码我需要禁用工作日,并且还有几天我该怎么做?有人可以帮助我吗?
Jquery Fiddle
$(document).ready(function(){
var Desingndate = $('#DesignIdUnavialble').html();
var splitdate = Desingndate.split(',');
// console.log(splitdate.length);
var arrDisabledDates = {};
for (var i = 0; i < splitdate.length; i++) {
//console.log(splitdate[i]);
arrDisabledDates[new Date(splitdate[i])] = new Date(splitdate[i]);
}
$("#iDate").datepicker({
dateFormat: 'dd-mm-yy',
beforeShowDay: function (dt) {
var bDisable = arrDisabledDates[dt];
if (bDisable) return [false, '', ''];
else return [true, '', ''];
}
});
});
答案 0 :(得分:1)
查看here
我修改了你的else语句以禁用所有工作日:
var bDisable = arrDisabledDates[dt];
if (bDisable) return [false, '', ''];
else {
return [dt.getDay() == 6 || dt.getDay() == 0,""];
}
答案 1 :(得分:1)
这可能对您有所帮助
function deadlinedates(date) {
dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
var day = date.getDay();
var Desingndate = $('#DesignIdUnavialble').html();
var splitdate = Desingndate.split(',');
var arrDisabledDates = {};
for (var i = 0; i < splitdate.length; i++) {
arrDisabledDates[new Date(splitdate[i])] = new Date(splitdate[i]);
}
var bDisable = arrDisabledDates[date];
if (bDisable) return [false, '', ''];
else return [(day != 0 && day != 6)];
}
$(document).ready(function(){
$("#iDate").datepicker({
dateFormat: 'dd-mm-yy',
beforeShowDay: deadlinedates
});
});