Diego
Diego

Reputation: 2372

datepicker How to show more years?

I am using bootstrap datepicker and when I open the dropdown to change the year, it shows only 20 years... The current year.. 10 years before and 10 after.

How can I change it and make it show 40 years.. ? the current year ,20 before and 10 after?

Is that posible?

This is what I have setted

 $(".datepicker").datepicker({
     changeMonth: true,
     changeYear: true,
 });
 $(".datepicker").datepicker("option", "showAnim", "clip");

This is the format I have

enter image description here Thanks

Upvotes: 0

Views: 47

Answers (2)

Moccaccino
Moccaccino

Reputation: 44

I think you need to set the startDate and endDate properties with this kind of syntax

$(".datepicker").datepicker({
     changeMonth: true,
     changeYear: true,
     startDate: '-20y',
     endDate: '+20y',
 });

Upvotes: 0

Suryateja KONDLA
Suryateja KONDLA

Reputation: 1601

$(".datepicker").datepicker({
    changeMonth: true,
    changeYear: true,
    yearRange: "-20:+10" // 20 years before and 10 years after the current year
});
$(".datepicker").datepicker("option", "showAnim", "clip");

you can use the yearRange

Upvotes: 1

Related Questions