我正在使用此代碼,但無法在datepicker中選擇任何日期。爲什麼?當我更改月份時,我可以選擇日期。我使用disableFunc
在日曆中禁用接下來的3天和週日。當我刪除那個disableFunc
我可以選擇日期。任何解決方案無法在JavaScript中選擇日期
Calendar.setup({
inputField : '_dob',
ifFormat : '%m/%e/%y',
button : '_dob_trig',
align : 'Bl',
singleClick : true,
disableFunc: function(date)
{
var first_day = new Date();
var second_day= new Date();
var third_day= new Date();
first_day.setDate(first_day.getDate());
if(first_day.getDay()===0)
{
first_day.setDate(first_day.getDate()+1);
}
second_day.setDate(first_day.getDate()+1);
if(second_day.getDay()===0)
{
second_day.setDate(first_day.getDate()+2);
}
third_day.setDate(second_day.getDate()+1);
if(third_day.getDay()===0)
{
third_day.setDate(second_day.getDate()+2);
}
var flag1 = first_day.getDate()===date.getDate() && first_day.getMonth()===date.getMonth() && first_day.getYear()===date.getYear();
var flag2 = second_day.getDate()===date.getDate() && second_day.getMonth()===date.getMonth() && second_day.getYear()===date.getYear();
var flag3 = third_day.getDate()===date.getDate() && third_day.getMonth()===date.getMonth() && third_day.getYear()===date.getYear();
if(date.getDay() === 0 || flag1 || flag2 || flag3)
{ return true; }
}
});
如果您一行一行地排除故障,那麼哪一行導致了意外的行爲? – roland 2014-10-20 11:50:27
'返回true;'導致意外的行爲,但爲什麼? – HungryDB 2014-10-20 11:52:57