无法让 jQueryUI 日期选择器显示我想要的日期范围
我想附加 jQueryUI datepicker 控件,以便用户可以选择他们的出生日期。
这是我的 Javascript 代码:
<script type="text/javascript">
$(document).ready(function() {
$("#dob").datepicker({
minDate: "-100Y",
maxDate: "+1M +10D",
changeMonth: true,
changeYear: true
});
});
</script>
所以我希望用户能够选择一个日期,可以是 100 年前,也可以是一个月后。 (虽然如果我可以将最大范围限制为“今天”之前一年会更好)
我的 jQuery 选项有什么问题,它似乎没有听我想要的。
它显示从 2002 年到 2012 年的年份。
I'd like to attach the jQueryUI datepicker control so users can pick their date of birth.
Here is my Javascript code:
<script type="text/javascript">
$(document).ready(function() {
$("#dob").datepicker({
minDate: "-100Y",
maxDate: "+1M +10D",
changeMonth: true,
changeYear: true
});
});
</script>
So I want users to be able to select a date, that's either 100 years earlier or a month from now. (Although it would be better if I could limit the max range to be a year before "today")
What is wrong with my jQuery options, it just doesn't seem to listen to what I want.
It's displaying the years from 2002 to 2012.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它正在听你想要听的内容。我在 jsFiddle 中测试了你的源代码,它运行良好。
默认情况下,“年份”下拉列表一次仅显示 10 项。您可以使用
yearRange
选项更改此设置(例如yearRange: 'c-100:c+10',
)。It is listening to what you want. I tested your source in jsFiddle, and it runs fine.
The "Year" dropdown will only display 10 items at a time by default. You can change this with the
yearRange
option (e.g.,yearRange: 'c-100:c+10',
).