jQuery UI Datepicker用于选择不显示所有月份的DOB [英] JQuery UI Datepicker Used To Select DOB Not Showing All Months

查看:102
本文介绍了jQuery UI Datepicker用于选择不显示所有月份的DOB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JQuery UI Datepicker,以便用户选择他们的出生日期(DOB).我的代码如下:-

I'm using JQuery UI Datepicker for users to select their date of birth (DOB). My codes are as follows :-

$('#DOB').datepicker({
    changeMonth: true,
    changeYear: true,
    maxDate: new Date(),
    yearRange: '-100:+0'
});

但是,我今天注意到,自从一月份开始,除非我将年份更改为上一年,否则不会显示其余的几个月(从2月到12月).我通过添加另一个选项做了一个临时解决方案

However, I noticed today that since its January, its not showing the rest of the months, (Feb to Dec) unless I changed the year to previous year. I did a temporary solution by adding another option

showMonthAfterYear: true

这不是一个完美的解决方案,因为它只有推动"用户在选择月份之前先选择年份.另一个解决方案是更改如下所示的选项

Its not a perfect fix as its only "pushing" users to select the year before selecting the months. Another solution was to change the options as shown below

yearRange: '-100:-1'

以上两种临时解决方案可能会对其他人有所帮助,但我希望有一个永久解决方案.再次感谢.

The above 2 temporary solutions might help others but I am hoping for a permanent solution if there is one. Thanks again.

推荐答案

我认为问题可能是maxDate:new Date().这将maxdate设置为今天,因此不会显示剩余的几个月

I think the issue may be maxDate: new Date(). That sets the maxdate to be today and will hence not show the rest of the months

这篇关于jQuery UI Datepicker用于选择不显示所有月份的DOB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆