This is my code below i need to disable the weekdays and also given days how can i do that ? Can some one help me ?
这是我的代码下面我需要禁用工作日,也给我几天我怎么能这样做?有人能帮我吗 ?
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, '', ''];
}
});
});
2 个解决方案
#1
1
This may help you
这可能对你有所帮助
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
});
});
#2
1
Check this out here
在这里查看
I modified your else statement to disable all weekdays:
我修改了你的else语句以禁用所有工作日:
var bDisable = arrDisabledDates[dt];
if (bDisable) return [false, '', ''];
else {
return [dt.getDay() == 6 || dt.getDay() == 0,""];
}
#1
1
This may help you
这可能对你有所帮助
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
});
});
#2
1
Check this out here
在这里查看
I modified your else statement to disable all weekdays:
我修改了你的else语句以禁用所有工作日:
var bDisable = arrDisabledDates[dt];
if (bDisable) return [false, '', ''];
else {
return [dt.getDay() == 6 || dt.getDay() == 0,""];
}