Reputation: 27703
The question is the in title. When I am showing the year list in Jquery-UI datepicker, can I control what year the list starts with?
UPDATED CODE
$(".datepicker").datepicker({
changeYear: true,
dateFormat: 'dd-M-yy',
altFormat: 'dd-M-yy',
minDate: '2001-01-01',
duration: ''
});
I need the year list to start with 2001. Is this possible with this control? The code above doesn't achieve this.
Upvotes: 2
Views: 2899
Reputation: 14435
You could accomplish it a couple of different ways:
$(".datepicker1").datepicker({ yearRange: "2001:2012", changeYear: true, defaultDate: new Date(2001,0,1)});
$(".datepicker2").datepicker({changeYear: true, defaultDate: new Date(2001,0,1)});
datepicker1
includes a defaultDate
but it doesn't have to. If you leave it out, it will default to today's date and the year select will start with the current year.
Note that datepicker2
includes the default year range in the year select box.
Upvotes: 2
Reputation: 6078
You can use the defaultDate
parameter.
Link.
If you want to set a specific year only, use the minDate
and maxDate
parameters (ie {minDate: '2010-01-01', maxDate: '2010-12-31'}
. It's all in the documentation. Give it a read.
Upvotes: 0