How to restrict jQuery UI Datepicker to disallow dates in the future?

Viewed 13364

I am using a jQuery UI Datepicker, such that only Sunday can be selected.

What I would like to happen is have it where no dates from the current date into the future can be selected. Here is the code I am using currently:

var daysToDisable = [1,2,3,4,5,6];

        $('#startdate').datepicker({
            beforeShowDay: disableSpecificWeekDays
        });

        function disableSpecificWeekDays(date) {
            var day = date.getDay();
            for (i = 0; i < daysToDisable.length; i++) {
                if ($.inArray(day, daysToDisable) != -1) {
                    return [false];
                }
            }
            return [true];
        }
3 Answers
Related