1

日付ピッカーを改善しようとしましたが、月曜日と木曜日にしか有効にできませんでした(最初はすべて無効にしました)が、特定の日付に問題があります。私は多くの可能性を試しましたが、毎月21日を選択するか、まったく機能しません。

今、私はその日付(2013,04,21)を有効にしようとしています(そして後でそれらのより多く)

  $( '#vfb-datum-75' ).datepicker({
              beforeShowDay: settings,
  });  

  function settings(date) {
      if (date.getDay() == 1)       
          { return [true, "","Works"];
      } else if (date.getDay() == 4)
          { return [true, "","Works"];
      } else if (date.getDate() == (2013,04,21))  <-- this doesn't work
          { return [true, "","Works"];
      } else { return [false,"",""]; 
  }}

手伝ってくれてありがとう。

4

1 に答える 1

2

http://jsfiddle.net/f7kAc/

年、日、月を比較できます。月はゼロベースであることを忘れないでください。

date.getDate() == 21 && date.getMonth() == 3 && date.getFullYear() == 2013

http://jsfiddle.net/f7kAc/1/

この方法を使用して、日付を別の日付にキャンプすることもできます。

date - new Date(2013, 3, 21) == 0

ただし、この関数を50以上の特別な日付に拡張する場合は、少しスッキリとした、より簡単に構成できるものが必要になる場合があります。

var specialDays = 
{2013 : 
  {
      3 : 
          {
              21 : [true, "", "WORKS"]
          },
      4 : 
          {
              15 : [true, "", "WORKS"],
              17 : [true, "", "WORKS"]
          },
  },
};

次に、あなたの関数で:

... else if (!!specialDays[date.getYear()] && !!specialDays[date.getYear()][date.getMonth()] && !!specialDays[date.getYear()][date.getMonth()][date.getDate()]) {
  return specialDays[date.getYear()][date.getMonth()][date.getDate()];
}
于 2013-03-11T19:49:46.117 に答える