jqueryjquery-uidatepickerjquery-ui-datepicker

Disable all Sundays (but allow Saturdays) in jQuery UI Calendar


I want to disable Sundays in jQuery UI calendar.

The docs show how to disable both days of the weekend:

$('#datepicker').datepicker({ minDate: 4,beforeShowDay: $.datepicker.noWeekends }); 

This will disable Saturdays and Sundays both. But I want to disable only Sunday. Is there any default option for this?

I know there is a "bad" way to solve this: beforeShowDay take true or false as params for every day, and write a function which returns true or false based upon each day. But I want a more reliable, less verbose way to do it.


Solution

  • try this

    $("#datepicker").datepicker({
        beforeShowDay: function(date) {
            var day = date.getDay();
            return [(day != 0), ''];
        }
    });