Disable/Enable selected date range on jQuery datepicker UI

后端 未结 3 2037
半阙折子戏
半阙折子戏 2020-12-03 12:15

So I have the following demo http://dev.driz.co.uk/week.html that shows a jQuery UI datepicker that has multiple instances for each month of the year.

I\'ve modified

3条回答
  •  囚心锁ツ
    2020-12-03 13:05

    If there is a requirement to disable a list of dates or like if in any reservation kind of projects where we have to disable some dates throughout the process. So you can use following code,

    $(function() {
        //This array containes all the disabled array
          datesToBeDisabled = ["2019-03-25", "2019-03-28"];
    
            $("#datepicker").datepicker({
              changeMonth: true,
              changeYear: true,
              minDate : 0,
              todayHighlight: 1,
              beforeShowDay: function (date) {
                  var dateStr = jQuery.datepicker.formatDate('yy-mm-dd', date);
                      return [datesToBeDisabled.indexOf(dateStr) == -1];
              },
    
            });
    });
    

提交回复
热议问题