这是我下面的代码,我需要禁用工作日,并且在给定的日子里我该怎么做?有人能帮我吗 ?
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, '', ''];
}
});
});
最佳答案
Working Fiddle
这可能对您有帮助
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
});
});