JQuery UI Datepicker, reverse the order of the year in the dropdowns

后端 未结 6 526
梦毁少年i
梦毁少年i 2020-12-01 16:58

I have a datepicker with changeyear: true. The \'year\' drop down displays the title as 2009, then instead of the next year below the title being 2008, 2007, 2006 and so on

6条回答
  •  借酒劲吻你
    2020-12-01 17:12

    I have an answer to you, but it's not exactly what you may want to hear.

    After searching the internet for a solution that would reverse the order of the years in the dropdown, I have come to this:

    {
        changeMonth: true
        , changeYear: true
        , yearRange: '-65:'
        , maxDate: '1999/12/31'
    }
    

    This will have the maxdate preselected, and therefore choosing a year you will automatically see the last entry, thereby being able to scroll up to choose an earlier date.

    Edit: yearRange is added arbitrarily, to create a starting point 65 years ago. maxDate is also chosen arbitrarily, as a date 12 years prior to writing this comment. Basically this menu will allow someone to choose an age between 12 and 65 years.

    It's not ideal, but it works well enough.

提交回复
热议问题