Jquery UI datepicker. Disable array of Dates

后端 未结 7 712
野的像风
野的像风 2020-11-22 02:21

I have been trying to search for a solution to my Jquery ui datepicker problem and I\'m having no luck. Here\'s what I\'m trying to do...

I have an application where

相关标签:
7条回答
  • 2020-11-22 03:03

    If you also want to block Sundays (or other days) as well as the array of dates, I use this code:

    jQuery(function($){
    
        var disabledDays = [
           "27-4-2016", "25-12-2016", "26-12-2016",
           "4-4-2017", "5-4-2017", "6-4-2017", "6-4-2016", "7-4-2017", "8-4-2017", "9-4-2017"
        ];
    
       //replace these with the id's of your datepickers
       $("#id-of-first-datepicker,#id-of-second-datepicker").datepicker({
          beforeShowDay: function(date){
             var day = date.getDay();
             var string = jQuery.datepicker.formatDate('d-m-yy', date);
             var isDisabled = ($.inArray(string, disabledDays) != -1);
    
             //day != 0 disables all Sundays
             return [day != 0 && !isDisabled];
          }
       });
    });   
    
    0 讨论(0)
提交回复
热议问题