Enable one specific date in jquery datepicker

前端 未结 2 1919
清歌不尽
清歌不尽 2021-01-24 19:03

I have a jQuery datepicker on my website, and I have disabled every first and second day (monday and tuesday) of the week. Also I have an array of days which are disabled (this

2条回答
  •  时光取名叫无心
    2021-01-24 19:54

    var vakantie = ["25-12-2018", "26-12-2018", "27-12-2018", "28-12-2018", "29-12-2018", "30-12-2018", "31-12-2018"];
    var enableDays = ["24-12-2018"];
    
    
    $("#datepicker").datepicker({beforeShowDay: function(dt) {
    var datestring = $.datepicker.formatDate('dd-mm-yy', dt);
        if($.inArray(datestring, enableDays) != -1) {
         return [true];
             }
        else{
         return [dt.getDay() == 1 || dt.getDay() == 2 ? false : true && vakantie.indexOf(datestring) == -1 ];
             }
    
       
        }});
    
      
      
      jQuery UI Datepicker - Default functionality
      
      
      
      
    
    
    
     
    

    Date:

    Try this..

    $("#datepicker").datepicker({beforeShowDay: function(dt) {
         var datestring = $.datepicker.formatDate('dd-mm-yy', dt);
         if($.inArray(datestring, enableDays) != -1) {
            return [true];
         }
         else{
          return [dt.getDay() == 1 || dt.getDay() == 2 ? false : true && vakantie.indexOf(datestring) == -1 ];
         }
    
    
    }});
    

提交回复
热议问题