开发者

How can I allow a user to answer dates before 1970 into a JQuery UI DatePicker widget?

开发者 https://www.devze.com 2023-01-22 03:32 出处:网络
I\'m working on a site that uses a Jquery UI datepicker to allow users to enter their date of birth.However, since the calender (intialized as follows), doesn\'t go before December 31st 1969, this wil

I'm working on a site that uses a Jquery UI datepicker to allow users to enter their date of birth. However, since the calender (intialized as follows), doesn't go before December 31st 1969, this will prevent users born before then from registering. How can I make it so that the date goes back all the w开发者_运维技巧ay to 1910 like intended?

picker.datepicker({
    defaultDate: (field.val() ? new Date(field.val() * 1000) : '-13y'),
    dateFormat: '@',
    changeMonth: true,
    changeYear: true,
    yearRange: '1910:2000',
    minDate: '1910-01-01'
});


Ugh... figured it out myself.

The minDate I gave it was an ISO 8601 date, but it was expecting a UNIX timestamp.

Changing it to -1893434400 made the picker work.

0

精彩评论

暂无评论...
验证码 换一张
取 消