jQuery UI Datepicker - allow only certain weekdays

后端 未结 5 539
我在风中等你
我在风中等你 2020-12-17 21:56

I\'m using jquery UI datepicker on a huge project and I realize now that I\'ll need to allow only certain weekdays on some areas. I read their documentation and didn\'t find

5条回答
  •  甜味超标
    2020-12-17 22:16

    Jean Mallet's answer (beforeShowDay: $.datepicker.noWeekends) is simple and elegant.

    However, if you're already calling a function using beforeShowDay (as I was in my case), here's how you can disable certain days of the week (in this case, Sunday and Saturday), chained along with the rest of your function:

    beforeShowDay: function (date) {
    
        /* your other function code here */
    
        if (date.getDay() > 0 && date.getDay() < 6) {
            return [true, ''];
        } else {
            return [false, ''];
        }
    }
    

提交回复
热议问题