防止过去日期的 jQuery 日期选择器 [英] jQuery datepicker to prevent past date
问题描述
如何在 jQuery datepicker 上禁用过去的日期?我寻找了选项,但似乎没有找到任何表明可以禁用过去日期的内容.
How do I disable past dates on jQuery datepicker? I looked for options but don't seem to find anything that indicates the ability to disable past dates.
更新:感谢你们的快速回复.我试过没有运气.天数仍然没有像我预期的那样变灰,并且仍然接受所选的过去日期.
UPDATE: Thanks yall for the quick response. I tried that with no luck. Days were still not grayed out as I expected and still accept the selected past date.
我试过了:
$('#datepicker').datepicker({ minDate: '0' });
不起作用.
我试过了:
$('#datepicker').datepicker({ minDate: new Date() });
还是不行.
它可以很好地显示日历小部件.它不会变灰或阻止过去几天的输入.我过去尝试过 minDate 和 maxDate 没有运气,所以我认为它一定不是它们.
It displays the calendar widget just fine. It just won't gray out or prevent input of past days. I've attempted the minDate and maxDate in the past with no luck so I figured it must not be them.
推荐答案
试试这个:
$("#datepicker").datepicker({ minDate: 0 });
删除 0
中的引号.
这篇关于防止过去日期的 jQuery 日期选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!