如何为 jQuery 日期选择器设置年份范围:1900 到当前年份,或 1900 到 9999
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8211591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can i set Year range for a jQuery Date Picker: 1900 to current year, or 1900 to 9999
提问by Developer
Hi all i used the Jquery Date picker
which works well enough for me. But i am having a small issue i.e i would like to set the Start year
from 1900
and End year
to Current Year
or 9999
..
Jquery Date picker
大家好,我使用了对我来说效果很好的。但我有一个小问题,即我想设置Start year
from1900
和End year
toCurrent Year
或9999
..
In the script i found this for year range
在脚本中我找到了这个 year range
yearRange: 'c-100:c+100'
If i move forward to some thing like 1800
i am unable to see the current year
.. What changes should i do here in order to see my years in a such a way that the years should be 1900-current year
or 1900-9999
如果我向前移动一些东西一样1800
,我无法看到的current year
。什么改变,我应该为了做这里看我这几年在这样一种方式,这些年来应该是1900-current year
或1900-9999
I tried this which works for me but as it is loading when the calendar loads it taking much time when my application runs
我试过这个对我有用但是因为它在日历加载时加载它在我的应用程序运行时需要很长时间
datepick({yearRange: '1900:9999'});
So any better option than this to achieve as per my requirement
因此,根据我的要求,任何比这更好的选择都可以实现
回答by malificent
try this:
尝试这个:
datepick({yearRange: '1900:' + new Date().getFullYear()});
回答by sohaib
$("#textBox").datepicker({
changeMonth: true, changeYear: true, yearRange: '1900:+0'
});
回答by Evaristo Colomby
This is what you need:
这是你需要的:
datepick({yearRange: "1900:+nn"});
Will set the range from the 1900 to the current year.
将设置从 1900 年到当前年份的范围。
回答by Rohit
$("#date").datepicker({ changeYear:true, yearRange: "1900:1999" });
$("#date").datepicker({ changeYear:true, yearRange: "1900:1999" });
回答by Pravin
you can set specific year of difference from current year
您可以设置与当前年份的特定年份差异
$( "#datepicker" ).datepicker({
changeYear: true,
minDate: '-116Y',
maxDate: '1Y',
yearRange: '-116',
});
回答by Dulith De Costa
You can use the following.
您可以使用以下内容。
$("#datepicker").datepicker({
changeMonth: true, // this will help you to change month as you like
changeYear: true, // this will help you to change years as you like
yearRange: "1900:9999"
});