我如何动态禁用特定日期,为此我正在使用此代码:-
<div id="disableVal_12">1,2</div>
<script>
var daysToDisable = [$("#disableVal_12").html()];
$('#datepickerPospond_2').datepicker({
firstDay:1,
beforeShowDay: disableSpecificWeekDays
});
function setDateZero(date){
return date < 10 ? '0' + date : date;
}
function disableSpecificWeekDays(date) {
var day = date.getDay();
var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
var date = setDateZero(d) + '/' + setDateZero((m+1)) + '/' + y;
for (i = 0; i < daysToDisable.length; i++) {
if ($.inArray(day, daysToDisable) == -1) {
return [false];
}else if ($.inArray(date , datesToDisable) == 1) {
return [false];
}
}
return [true];
}
</script>
如果有人有更好的解决方案,请告诉我。