RollerCosta
RollerCosta

Reputation: 5196

After setting yearRange: '-90:-15' Jquery Datepicker picking current Year(initially) why?

     $("#dob").datepicker({
            changeMonth: true,
            changeYear: true,
            dateFormat: 'dd-M-yy',
            yearRange: '-90:-15'

        });


At year dropdown calender filled with range 1922-1997 and showing 1922 as initial value.
But still when I pick a date from this calender , it shows 2012 in textbox field, why?.

Upvotes: 1

Views: 1191

Answers (3)

RollerCosta
RollerCosta

Reputation: 5196

 $("#dob").datepicker("option", "defaultDate", '-90y');


Secondly one can also place defauleDate as below

     $("#dob").datepicker({
            changeMonth: true,
            changeYear: true,
            dateFormat: 'dd-M-yy',
            yearRange: '-90:-15',
            defaultDate:'-90y'

        });

Upvotes: 5

Ufuk Hacıoğulları
Ufuk Hacıoğulları

Reputation: 38478

yearRange option is not used for displaying default date. It just sets the limits of the years you can choose.

You can set the value when displaying the page from server side or use the defaultDate option.

Upvotes: 1

Adam Merrifield
Adam Merrifield

Reputation: 10407

I believe you want defaultDate: -90y

Upvotes: 1

Related Questions