【发布时间】:2011-09-13 01:08:13
【问题描述】:
我需要让我的 jQueryUI 日期选择器的 maxDate 根据日期动态更新。现在,正如您将在下面看到的,有一个用于禁用周一至周四的功能,因为我们的团队只能在周五至周日报告问题。所以我需要做的是让团队可以在周末继续报告,但下周末直到周四才能继续报告。例如,今天是周一,团队仍然可以报告上周四至周日的问题,但直到周四才能选择下周末的日期。这可能吗?
这是我目前的代码:
var fullDate = new Date();
var twoDigitMonth = ((fullDate.getMonth().length+1) === 1)? (fullDate.getMonth()+1) : '0' + (fullDate.getMonth()+1);
$('#startdate').datepicker({
maxDate: twoDigitMonth + "/" + fullDate.getDate() + "/" + fullDate.getFullYear(),
beforeShowDay: disableSpecificWeekDays
});
function disableSpecificWeekDays(date) {
if((date.getDay()==0) || (date.getDay() == 5) || (date.getDay() == 6) ){
return [true];
}else{
return [false];
}
}
【问题讨论】:
标签: jquery jquery-ui jquery-ui-datepicker