Dambo Dambo - 1 year ago 160
jQuery Question

How to make certain months unselectable with datepicker?

I would like to make certain months unselectable. So for example the user should be able to navigate different years, but 'November' will always be greyed-out (or even better, completely excluded from the widget).

Right now, I have tried something like this:



<input type="text" id="datepicker" />


$(document).ready(function() {
beforeShowMonth: function (date) {
if (date.getMonth() == 10) {
return [false];

Answer Source

The jQueryUI datepicker does not have a beforeShowMonth property, only beforeShowDay. You also need to return [true] from that function if the date is valid. With that in mind, try this:

    beforeShowDay: function(date) {
        return [date.getMonth() != 10];

Updated fiddle

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download