JQuery datepicker 允许用户设置年份
我正在使用带有以下设置的 datepicker jquery 插件。
$("#date").datepicker({
showButtonPanel: true,
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true
});
现在我想做的是允许用户设置年份。我的意思是手动更改选择下拉列表的输入。
有什么设置可以做到这一点吗?
我想这样做的原因是因为我不知道用户是否选择 1920 年或 2220 年或任何年份中的日期。所以我没有一个好的默认日期值。如果你必须点击 20 次才能从 2000 年到 1600 年,那么下拉界面就不那么用户友好了。
编辑: 我想做的是来自 keith-wood.name/datepick.html#monthyear 的“显示无限年数:”。有没有与标准 jquery datepicker 类似的东西?我在 jquery datepicker 文档中找不到设置yearRange: 'any'。
I am using the datepicker jquery plugin with the settings below.
$("#date").datepicker({
showButtonPanel: true,
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true
});
Now what i want to do is allowing the user to set the year. I mean by manual changing the input of the selection drop down.
Is there any setting to do that ?
The reason I would like to do that is because I don't know, if the user is selecting a date from the year 1920 or 2220 or what ever year. So I don't have a good default date value. And the dropdown interface isn't that userfriendly if you have to click 20 times to get from the year 2000 to the year 1600.
Edit:
What I want to do is the "Show unlimited years:" from keith-wood.name/datepick.html#monthyear. Is there anything similar with the standard jquery datepicker. I can't find the setting yearRange: 'any' in the jquery datepicker documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
来指定年份范围
您可以通过添加属性 。例如:
You can specify a range of years by adding
to your attributes. For example:
已经显示一个选择框..那么问题是什么?
对于手动输入年份,只需创建自己的输入文本?
already displaying a selectbox.. so whats the problem??
for manually input of the year just create own input text?
您只需输入以下两行即可设置年份和月份。
这里日期是输入的ID
You can set year and also month just putting following two lines.
Here date is input ID