JQuery datepicker allows user to set year

I am using jqery datepicker plugin with settings below.

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

Now what I want to do allows the user to set the year. I mean, if you manually change the selection input.

Are there any settings for this?

The reason I would like to do this is because I don’t know if the user selects a date from 1920 or 2220 or that year. Therefore, I do not have a good default date value. And the drop-down interface is not so convenient if you need to click 20 times to get from 2000 to 1600.

Edit: What I want to do is "Show unlimited years:" from keith-wood.name/datepick.html#monthyear. Is there something similar with the standard jquery datepicker. I cannot find the setting yearRange: "any" in the jQuery datepicker documentation.

+8
source share
3 answers
 changeYear: true 

already displays selectbox .. so what is the problem ?? for manual year entry just create your own input text?

+10
source

You can specify the range of years by adding

 yearRange: "1930:2010" 

to your attributes. For instance:

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

You can set the year as well as the month by simply putting the following two lines.

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

Here, the date is the input identifier

0
source

Source: https://habr.com/ru/post/903275/


All Articles