简体   繁体   English

阻止数据选择器中的特定日期

[英]block a specific date in datapicker

I have a datapicker on my site where I have Monday and Tuesday blocked. 我的网站上有一个数据选择器,星期一和星期二都被阻止了。 How can I block a very specific date eg 05/06/2013 如何封锁特定日期,例如2013年5月6日

The code I have now is as follows 我现在拥有的代码如下

noMondaysandtuesdays: function(date) {
    var day = date.getDay();
return [(day == 0 || day == 3 || day == 4 || day == 5|| day == 6)];

Try this, here is the demo you can simply put desired dates which have to be blocked in unavailableDates array 试试这个,这里是演示,您可以简单地将所需的日期放入unavailableDates数组中

 var unavailableDates = ["6-6-2013"];

    function unavailable(date) 
    {
      var dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" +  date.getFullYear();
        var day = date.getDay();
      if ($.inArray(dmy, unavailableDates) < 0 && day != 1 && day != 2) 
      {
        return [true,"",""];
      } 
      else
      {
        return [false,"",""];
      }
    }
    $(function()
      {  $('#date').datepicker({ beforeShowDay: unavailable });}

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM