views:

982

answers:

4

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?

+5  A: 

$.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.

Randy
A: 

Can you do the opposite and have the input what dates are selectable and leave all the rest filtered out?

A: 

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), ""]
}
A: 

upon googling, found this thread. But i have no idea how to implement this. my jQueryUI calendar just needs to disable all days except for saturday. Any thoughts?

Ramon