简体   繁体   中英

How to disable holidays with weekends and previous days after a certain time from jquery datepicker?

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?

 <!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

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), ''];
      }; 

  });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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