目前我有这个代码,可以让我更改特殊的圣诞节交货日期。今年我们提供 3 个交货日期 - 21、22 和 23。我如何操作此代码以允许这样的范围?
当前代码:
setValidDaysForNationwideDelivery: function(date) {
if ((date.getMonth() == 11) && (date.getDate() == 21)) {
return [true, ""];
}
}
最佳答案
只需使用范围:
setValidDaysForNationwideDelivery: function(date) {
if (date.getMonth() == 11 && date.getDate() >= 21 && date.getDate() <= 23) {
return [true, ""]; }
<小时/>
旁注:每个比较周围的额外 ()
(date.getMonth() == 11
) 绝对没有效果,我已经在上面删除了它们。
关于javascript - 如何在 Js 中创建交货日期范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26753824/