gpt4 book ai didi

php - 禁用日期选择器中的过去日期并仅选择 "monday"

转载 作者:行者123 更新时间:2023-12-01 04:40:07 25 4
gpt4 key购买 nike

我的输入文本框中有这个日期选择器,它在日期选择器和所选内容中也运行良好。我的问题是想要禁用过去的日期,并且仅禁用 future 选定的日期“星期一”。下面是我的代码

<input type='text' name='datepicker' id='datepicker' placeholder='Date:' class='form-control'>
$(function() {
$("#datepicker").datepicker({
beforeShowDay: function (date) {
//getDate() returns the day (0-31)
if (date.getDay() == 1 ) {
return [true, ''];
}
return [false, ''];
}
});
});

我的代码发生的情况是选择了星期一,但过去的日期并未被禁用。有人可以帮我弄清楚如何禁用过去的日期吗?TIA

最佳答案

试试这个...通过 mindate=0;

$(function() {
$("#datepicker").datepicker({
minDate:0,
beforeShowDay: function (date) {
//getDate() returns the day (0-31)
if (date.getDay() == 1 ) {
return [true, ''];
}
return [false, ''];
}
});
});

关于php - 禁用日期选择器中的过去日期并仅选择 "monday",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40151218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com