Array of string variables to disable some date in jQuery Datepicker

Viewed 71

I have an array in javascript like this:

enter image description here

I tried to disable these dates using datepicker beforeShowday config like this:

                     beforeShowDay: function(date) {
                      var string = jQuery.datepicker.formatDate('dd/mm/yy', calendar.holidays);
                      return [ array.indexOf(string) == -1 ]
                    }

but the dates that i want to disable keeps appearing

1 Answers

the doc:

The function is called for each day in the datepicker before it is displayed.

So our code should: for the date passed in, which will be every date that's to be displayed, jQuery.datepicker.formatDate it, and check whether the resulting string is one of the holidays.

Something like:

beforeShowDay: function(date) {
    var string = jQuery.datepicker.formatDate('mm/dd/yy', date);
    return [ calendar.holidays.indexOf(string) == -1 ]
}
Related