Skip to main content

Disable specific days of the week on jQuery UI datepicker



Possible Duplicate:

Can the jQuery UI Datepicker be made to disable Saturdays and Sundays (and holidays)?




I would like to disable certain days like every monday or every tuesday or every monday, thursday friday, etc. on a jQuery UI datepicker.



I tried to play with beforeShowDay, but that requires a specific date. I just want to disable an entire day of the week.



Update: Thanks for the suggested solutions, but they all work for specific dates. What if I wanted to disable every single Monday and Tuesday for the entire year. How would I do that?


Source: Tips4allCCNA FINAL EXAM

Comments

  1. You can ue the beforeShowDate event of the datepicker combined with Date.getDay() to do what you want, like this:

    ​$("#datepicker").datepicker({
    beforeShowDay: function(date) {
    var day = date.getDay();
    return [(day != 1 && day != 2)];
    }
    })​​​​​;​


    You can see a working demo here, this just takes the date, checks if it's a Monday (1) or Tuesday (2) and returns false for the first array entry if that's the case.

    ReplyDelete

Post a Comment

Popular posts from this blog

Wildcards in a hosts file

I want to setup my local development machine so that any requests for *.local are redirected to localhost . The idea is that as I develop multiple sites, I can just add vhosts to Apache called site1.local , site2.local etc, and have them all resolve to localhost , while Apache serves a different site accordingly.