Datepicker - Disable next 3 days if its friday past 11AM

I got some trouble making an awesome feature for my datepicker. The things i want to do is:

I have been look around other examples on stackoverflow but nothing worked. So nows my time to try my luck!

Many thanks beforehand!

Upvotes: 0

Views: 787

Answers (1)

ryanyuyu
ryanyuyu

Reputation: 6486

Your current javascript function doesn't take the day of the week into account. Just add some logic to also check that the current day is a Friday.

...
beforeShow : function(){
        var dateTime = new Date();
        var hour = dateTime.getHours();
        var dayOfWeek = dateTime.getDay(); //check the day of the week
        if(dayOfWeek == 5  &&  hour >= 11) {
            $(this).datepicker( "option", "minDate", "+2" );
        }
    }

Note that the getDay() function returns the day of the week as an 0-indexed integer, with Sunday being 0, and Saturday being 6. So date.getDay() == 5 is a Friday.

Upvotes: 1

Related Questions