简体   繁体   English

jQuery DatePicker,年份可选

[英]JQuery DatePicker with year optional

I need to make the year optional when selecting a date in the JQuery DatePicker. 在JQuery DatePicker中选择日期时,我需要使年份为可选。 Please note the word optional . 请注意“ 可选 ”一词。 I do not want to remove the year, I just want to make it optional. 我不想删除年份,我只想将其设为可选。

Why? 为什么? I am storing date of birth and sometimes people don't give the year they were born. 我要存储出生日期,有时人们不给出出生年份。

I don't think this is possible with the built in DatePicker. 我认为内置DatePicker不可能做到这一点。 If not, does anyone know of another solution I could use? 如果没有,是否有人知道我可以使用的其他解决方案?

Appreciate your help in advance! 提前感谢您的帮助!

Ben

JQuery does not allow this sort of an option. JQuery不允许这种选项。 You can anyway take a look at this plugin which allows you to select only the month. 无论如何,您都可以查看此插件 ,该插件仅允许您选择月份。 If you want to use the year as optional, you might check this . 如果要使用年份作为可选,则可以选中

Try this, change the date format however you want. 尝试执行此操作,然后根据需要更改日期格式。 This one will enter "01-27"(mm-dd) in your textbox. 这将在您的文本框中输入“ 01-27”(mm-dd)。

 $.datepicker.setDefaults({
        inline: true,
        changeMonth: true,
        dateFormat: "mm-dd",
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM