Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery UI: Filter selectable dates on datepicker

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?

like image 994
JamesSugrue Avatar asked Aug 17 '26 05:08

JamesSugrue


1 Answers

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

like image 57
Randy Avatar answered Aug 18 '26 18:08

Randy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!