JQuery datepicker 允许用户设置年份

发布于 2024-12-20 02:35:59 字数 556 浏览 6 评论 0原文

我正在使用带有以下设置的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

冬天的雪花 2024-12-27 02:35:59

来指定年份范围

yearRange: "1930:2010"

您可以通过添加属性 。例如:

 $( "#datepicker" ).datepicker({
     changeMonth: true,
     changeYear: true,
     yearRange: "1930:2010"
 });

You can specify a range of years by adding

yearRange: "1930:2010"

to your attributes. For example:

 $( "#datepicker" ).datepicker({
     changeMonth: true,
     changeYear: true,
     yearRange: "1930:2010"
 });
一绘本一梦想 2024-12-27 02:35:59
changeYear: true

已经显示一个选择框..那么问题是什么?
对于手动输入年份,只需创建自己的输入文本?

changeYear: true

already displaying a selectbox.. so whats the problem??
for manually input of the year just create own input text?

两人的回忆 2024-12-27 02:35:59
jQuery("#date").datepicker({
    dateFormat: "dd-mm-yy",
    changeMonth: true,
    changeYear: true,
    yearRange: "-80:+00" // Use this to get the list of years you more than default range.
});
jQuery("#date").datepicker({
    dateFormat: "dd-mm-yy",
    changeMonth: true,
    changeYear: true,
    yearRange: "-80:+00" // Use this to get the list of years you more than default range.
});
云雾 2024-12-27 02:35:59

您只需输入以下两行即可设置年份和月份。

$("#date").datepicker({
    changeMonth: true,
    changeYear: true
});

这里日期是输入的ID

You can set year and also month just putting following two lines.

$("#date").datepicker({
    changeMonth: true,
    changeYear: true
});

Here date is input ID

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文