jQuery UI 日期选择器;禁用第二个和第四个星期六

jQuery UI Datepicker; Disable second and fourth saturday

抱歉,我在Whosebug 中搜索了很多,但没有找到。
我想禁用每个月的第二个星期六和第四个星期六。我已经在 beforeShowDay.
中拥有函数 我现在的 beforeShowDay.

beforeShowDay: function(date) {
  var show = true;
  for( var k in holidays){if(date.getDay()==holidays[k]) show=false;}
  return [show];
}

我也想 return 第二个和第四个星期六为 false。

我找到了以下内容:https://www.codeproject.com/Questions/1067759/How-To-disable-nd-th-saturday-sunday-and-Holiday-d

这里有对你有用的信息:

var week = 0 | date.getDate() / 7 //get the week
//check if it's second week or fourth week
if (week == 1 || week == 3) {
  if (day == 6)  { //check for satruday
    return [false];
  }
}

所以你的脚本看起来像:

beforeShowDay: function(date) {
  var result = [true, "open"];
  var day = date.getDay();
  var week = 0 | date.getDate() / 7;
  $.each(holidays, function(i, holiday){
    if(day == holiday){
      result = [false, "holiday"];
    }
  });
  if ((week == 1 || week == 3) && day == 6) {
    result = [false, "closed"]
  }
  return result;
}