如何在jquery datepicker的一段时间后禁用周末和前几天的假期?

时间:2022-11-30 09:17:40

I want to create a jQuery datepicker where sunday will be disabled and the previous days will be disabled including the present day after 3.30PM, and holidays also. Here is what I have done as far. can anyone help me how I can add the holidays?

我想创建一个jQuery日期选择器,其中星期日将被禁用,前几天将被禁用,包括当天下午3点30分以及假期。这是我到目前为止所做的。任何人都可以帮助我如何添加假期?

<!DOCTYPE html>
<html>
    <head>
        <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

        <script>


        var currentTime = new Date();

        if (currentTime.getHours() >=15 && currentTime.getMinutes() >=30) {
            $(document).ready(function() {
                $('#datepicker').datepicker({
                        minDate: 1,						
                    beforeShowDay: noSunday
                  });

                  function noSunday(date){
                      var day = date.getDay();
                                  return [(day > 0), ''];
                  }; 
            });
        } else {
            $(document).ready(function() {
                $('#datepicker').datepicker({
                        minDate: 0,						
                    beforeShowDay: noSunday
                  });

                  function noSunday(date){
                      var day = date.getDay();
                                  return [(day > 0), ''];
                  }; 
            });
        }
        </script>
    </head>
    <body>
        <form>
            <input id="datepicker" />
        </form>
    </body>
</html>

The Sunday disable and the before days are disabled I just need help to disable holiday

周日禁用和前几天被禁用我只需要帮助来禁用假期

1 个解决方案

#1


0  

var currentTime = new Date();
var timeCond = currentTime.getHours() >=15 && currentTime.getMinutes() >=30;
var holidays = ["1/12/2016"]; // add holidays
$(document).ready(function() {
    $('#datepicker').datepicker({
        minDate: timeCond?1:0,                      
        beforeShowDay: visibilityHandler
      });
      function visibilityHandler(date){
          if(holidays.indexOf(date.toLocaleDateString()) != -1)
             return [false,'']
          return noSunday(date);
      }

      function noSunday(date){
          var day = date.getDay();
                      return [(day > 0), ''];
      }; 

  });

#1


0  

var currentTime = new Date();
var timeCond = currentTime.getHours() >=15 && currentTime.getMinutes() >=30;
var holidays = ["1/12/2016"]; // add holidays
$(document).ready(function() {
    $('#datepicker').datepicker({
        minDate: timeCond?1:0,                      
        beforeShowDay: visibilityHandler
      });
      function visibilityHandler(date){
          if(holidays.indexOf(date.toLocaleDateString()) != -1)
             return [false,'']
          return noSunday(date);
      }

      function noSunday(date){
          var day = date.getDay();
                      return [(day > 0), ''];
      }; 

  });