【问题标题】:jQuery UI datepicker, "disabled days" not working in IE 7 and 8jQuery UI datepicker,“禁用天数”在 IE 7 和 8 中不起作用
【发布时间】:2011-02-22 08:30:43
【问题描述】:

我使用以下函数禁用日期选择器日历中从 2011-02-13 到 2011-02-18 的日期:

function no_disabled_days(date){
               dateStr1 = '2011-02-13T00:00:00';                   
               dateStr2= '2011-02-18T00:00:00';

               disabled_start_day = new Date(dateStr1);
               disabled_end_day = new Date(dateStr2);

               if(date >= disabled_start_day && date <= disabled_end_day){
                   return [false];
               }


             return [true];

  }

$("#reserve_date").datepicker({
            beforeShowDay: no_disabled_Days
});

例如,如果 dateStr1='2011-02-13T00:00:00'dateStr2='2011-02-18T00:00:00',则从 2011-02-132011-02-18 的日子被禁用

ChromeFirfox 浏览器中一切正常,但是,当我在 IE 7 和 8 中进行测试时,一切都无法正常工作,只有日期选择器日历可以弹出,disabled_days 未被禁用。为什么?如何更改我的代码以使其在 IE 7 和 8 中也能正常工作?

顺便说一句,'T00:00:00' 字符串是需要来解决 Firefox 中的本地时区问题,(以使禁用天在 Firefox 中工作) ,看看我的另一篇帖子here

【问题讨论】:

  • 如果不需要00:00:00,请尝试删除它。
  • 您好,需要,一开始我没有使用T00:00:00,后来发现在Firefox中导致本地时区问题,只有T00:00:00,问题可能是避免。

标签: jquery jquery-ui jquery-ui-datepicker


【解决方案1】:

IE 的问题在于你的格式...

试试这个

alert(new Date('2011-02-13T00:00:00').getDate()); // alerts NaN, your current format
alert(new Date('2011/02/13T00:00:00').getDate()); // alerts 13
alert(new Date('02-13-2011T00:00:00').getDate()); // alerts 13

在 IE 7 上测试

【讨论】:

  • 是的,但是如果我将其更改为 2011/02/13T00:00:00,Firefox 将无法正常工作。似乎没有独特的解决方案可以使其同时在 Chrome、Firefox 和 IE 7,8 中运行...
猜你喜欢
  • 2011-11-30
  • 2023-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-23
  • 1970-01-01
相关资源
最近更新 更多