Reputation: 15011
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?
Upvotes: 3
Views: 3937
Reputation:
Yes you can.
i.e. If you only want the user to be able to select Mondays you would add something like:
onlyMondays: function(date){
var day = date.getDay();
return [(day == 1), ""]
}
Upvotes: 0
Reputation:
Can you do the opposite and have the input what dates are selectable and leave all the rest filtered out?
Upvotes: 0
Reputation: 4023
$.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.
Upvotes: 6