In jquery ui date-picker how to allow selection of specific weekdays and disable the other weekdays

前端 未结 2 1819
天命终不由人
天命终不由人 2021-01-01 05:25

I need to limit the jquery ui date picker to only have future Tuesdays and Thursdays as selectable days.

How can I accomplish this?

2条回答
  •  旧时难觅i
    2021-01-01 05:46

    It's all in the documentation. The function beforeShowDay will do what you want.

    http://api.jqueryui.com/datepicker/#option-beforeShowDay

    My use was different days but I ended up with beforeShowDay calling my limitdays function

    function limitDays(date){
    
    var day = date.getDay();
    
      // Only make Mon, Tues, and Thurs selectable
      if(day == 1 || day == 2 || day == 4){
        return [true, ''];
      }else{
        return [false, ''];
      }
    }
    

提交回复
热议问题