We help IT Professionals succeed at work.

Setting the default date for Year drop down using jQuery UI Date Picker

curiouswebster
on
I use the following:

yearRange: "-75:-20",


How do I set the currently displayed value for the Year drop down to be the highest year in the list?  In this case that value is 1990.

Thanks!
Comment
Watch Question

From the docs

defaultDate

Type:
    Date, Number, String
Default:
    null

Set the date to highlight on first opening if the field is blank. Specify either an actual date via a Date object or as a string in the current dateFormat, or a number of days from today (e.g. +7) or a string of values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days, e.g. '+1m +7d'), or null for today.
Code examples

Initialize a datepicker with the defaultDate option specified.

    $( ".selector" ).datepicker({ defaultDate: +7 });

In your case, you'd probably want defaultDate: '-21y'
curiouswebsterSoftware Engineer

Author

Commented:
Thanks!