Question

Im using DateTimePicker for my jQuery UI project and it offers me dates between 2001 and 2040. How can i change it, so it offers me years from 1950 and on...

I tried min="1950-01-01" in input form, but it doesn't work.

Code

<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Display month &amp; year menus</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
    $(function () {
        $("#datepicker").datepicker({
            changeMonth: true,
            changeYear: true
        });
    });
</script>

Thanks!

Was it helpful?

Solution

Use the yearRange option. This example will set the range to +/- 50 of the current year:

$( "#datepicker" ).datepicker({
                              changeMonth: true,
                              changeYear: true, 
                              yearRange: "-50:+50"
                              });

You can also set it relative to the selected year or an absolute range.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top