Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 644
Developer Avatar asked Nov 21 '11 12:11

Developer


People also ask

How do you change the year on a date picker?

There's a changeYear property on the datepicker that you can set to true . This will render a select list from which you can choose the year you'd like. Save this answer.

How would you restrict date picker selection based on the entry in another date field?

The requirement is also to be able to use dates in the format "dd-MMM-yy". For example, in the first date field, the user selects 26-Nov-16. Then, when they click on the date picker for the second date field, the earliest date they are able to select is 26 Nov.

How do I display only the year in datepicker?

I will suggest to add formate on datepicker as "YYYY" so it will only show years inside it.


1 Answers

try this:

datepick({yearRange: '1900:' + new Date().getFullYear()});
like image 104
malificent Avatar answered Nov 05 '22 19:11

malificent