jQuery UI: Datepicker set year range dropdown to 100 years

后端 未结 6 1756
粉色の甜心
粉色の甜心 2020-12-07 07:18

Using the Datepicker the year drop down by default shows only 10 years. The user has to click the last year in order to get more years added.

How can we set the init

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 07:58

    You can set the year range using this option per documentation here http://api.jqueryui.com/datepicker/#option-yearRange

    yearRange: '1950:2013', // specifying a hard coded year range
    

    or this way

    yearRange: "-100:+0", // last hundred years
    

    From the Docs

    Default: "c-10:c+10"

    The range of years displayed in the year drop-down: either relative to today's year ("-nn:+nn"), relative to the currently selected year ("c-nn:c+nn"), absolute ("nnnn:nnnn"), or combinations of these formats ("nnnn:-nn"). Note that this option only affects what appears in the drop-down, to restrict which dates may be selected use the minDate and/or maxDate options.

提交回复
热议问题