How can i set Year range for a jQuery Date Picker: 1900 to current year, or 1900 to 9999

核能气质少年 提交于 2019-12-20 11:51:41

问题


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..

In the script i found this for 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

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


回答1:


try this:

datepick({yearRange: '1900:' + new Date().getFullYear()});



回答2:


$("#textBox").datepicker({
    changeMonth: true, changeYear: true, yearRange: '1900:+0'
});



回答3:


This is what you need:

datepick({yearRange: "1900:+nn"});

Will set the range from the 1900 to the current year.




回答4:


$("#date").datepicker({ changeYear:true, yearRange: "1900:1999" });




回答5:


you can set specific year of difference from current year

    $( "#datepicker" ).datepicker({ 
        changeYear: true,
         minDate: '-116Y',
         maxDate: '1Y', 
         yearRange: '-116',
     });



回答6:


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"
 });


来源:https://stackoverflow.com/questions/8211591/how-can-i-set-year-range-for-a-jquery-date-picker-1900-to-current-year-or-1900

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!