JQuery UI Date Picker minDate and date range It seems pretty broken

When I set minDate var to something below 2001, it just won't go below 2001 for the lower limit.

I tried to insert the minDate value as a string, number or Date object (as the documentation states that you can use any of the three types)

No matter how I enter the value, it will not be lower than 2001.

Any ideas?

+4
source share
2 answers

This is because if you show the year with the changeYear option, you must also set the yearRange , which otherwise defaults to +10: -10 For example:

 $( "#datepicker" ).datepicker({ minDate: "-20Y",//go back 20 years changeYear:true,//show a drop down to change year maxDate: "+1M +10D", yearRange: 'c-100:c+10'//Show up to 100 years before and ten years after in the dropdown }); 

fiddle here: http://jsfiddle.net/rUq7M/

+9
source

You might like the following: the values ​​given here are for illustration only, you need to use the values ​​based on your requirements.

 $(function () { $("#datepicker").datepicker({ changeMonth: true, changeYear: true, dateFormat: "yy-mm-dd", yearRange: '1934:2004', defaultDate: '1980-01-01' }); }); 
+4
source

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


All Articles