Jquery datepicker years change

后端 未结 5 1186
Happy的楠姐
Happy的楠姐 2021-02-11 23:09

I am using datepicker of jquery for a field to set date of birth, while default picker is displayed which gives option to scroll to date monthly and sounds tedious. Is there a w

5条回答
  •  甜味超标
    2021-02-11 23:26

    changeYear property lets you enable a year dropdown. Also might be helpful to use yearRange property to control number of years they see in the dropdown, by default it's from -10 to +10 years.

    $('#date').datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange: "-40:+40"
    });
    

    Details from original documentation:

    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.

提交回复
热议问题