JQuery UI: Filter selectable dates on datepicker

datepickerjquery

I want to filter the selectable dates on a datepicker. I basically need to filter by work days – i.e. make holidays and weekends not selectable.

I know you can specify dates using a function in the beforeShowDate: and you can also use $.datepicker.noWeekends.

Question is: can you do both?

Best Solution

$.datepicker.noWeekends is a pretty simple bit of code:

function (date) { 
    var day = date.getDay(); 
    return [day > 0 && day < 6, ""]; 
}

Since you're going to have to write up the function for holidays, you can just include this logic in that function too.