Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery UI Date Picker... only allow Fridays?

I want to only allow users to select Fridays. Basically they are choosing the start date for a schedule, and the schedules always must start on a Friday.

I am not really concerned with whether the other days are displayed or not as long as if they are displayed, then they are disabled.

like image 987
JD Isaacks Avatar asked Jun 30 '10 16:06

JD Isaacks


1 Answers

You can use the beforeShowDate option, like this:

​$("#datepicker").datepicker({
    beforeShowDay: function(date) {
        return [date.getDay() == 5];
    }
})​​​​​;​

You can try a demo here, we're just checking if the .getDay() on the date it's trying to show is 5 (Friday), and if so true is the first element in the array, false otherwise, which disables the date in the picker.

like image 181
Nick Craver Avatar answered Sep 19 '22 18:09

Nick Craver