我正在使用jQuery datapicker插件,并使用noWeekends函数禁用周末。唯一的问题是,我需要启用一个周末的一天。有谁知道如何做到这一点?这是我正在使用的代码...
var disabledDays = [<?php echo rtrim($daysClosed, ","); ?>];
function nationalDays(date) {
var m = date.getMonth(),
d = date.getDate(),
y = date.getFullYear();
for (i = 0; i < disabledDays.length; i++) {
if ($.inArray((m+1) + '-' + d + '-' + y,disabledDays) != -1) {
return [false, disabledDays[i][2] + '_day'];
}
}
return [true, ''];
}
function noWeekendsOrHolidays(date) {
var noWeekend = jQuery.datepicker.noWeekends(date);
return noWeekend[0] ? nationalDays(date) : noWeekend;
jQuery('.cart-contents i').html(noWeekend);
}
jQuery(document).ready(function(){
jQuery('#e_deliverydate').datepicker({
dateFormat: 'dd/mm/yy',
beforeShowDay: noWeekendsOrHolidays,
minDate:<?php echo $delivMin; ?>,
maxDate:'<?php echo $oneYearOn; ?>'
});
});
提前致谢:)
答案 0 :(得分:1)
$("#datepicker").datepicker({
beforeShowDay: function (date) {
var day = date.getDay();
return [(day != 6)]; //0-Sunday 6-Saturday
}
});
<小时/> 在OP的评论
之后更新
停用所有28th Dec
var array = ["28-12"];
$("#datepicker").datepicker({
beforeShowDay: function (date) {
var string = jQuery.datepicker.formatDate('dd-mm', date);
return [array.indexOf(string) == -1]
}
});
<小时/> 禁用
28th Dec 2013
var array = ["28-12-2013"]; // add dates you want to disable here
$("#datepicker").datepicker({
beforeShowDay: function (date) {
var string = jQuery.datepicker.formatDate('dd-mm-yy', date);
return [array.indexOf(string) == -1]
}
});
<小时/> 启用
28th Dec
$("#datepicker").datepicker({
beforeShowDay: function (date) {
var string = jQuery.datepicker.formatDate('dd-mm-yy', date);
if (string == "28-12-2013") {
return [true];
} else {
var day = date.getDay();
return [(day != 6)];
}
}
});