当我在输入字段中输入字符串 01/01/24
时,它会返回日期 01/01/2024
但如果我输入 01/01/25
它返回日期 01/01/1925
。
是否可以阻止此事件并始终返回 2000
之后的日期?
用户不希望我使用 dd/mm/yy
更改 dateFormat
,因此我只能使用 dd/mm 格式/y
.
这是我用来创建日期选择器的js:
$('.hasDatepicker').datepicker({
showOn: "button",
buttonImage: imagePrefix + "/img/calendar_1.png",
buttonImageOnly: true,
dateFormat: "dd/mm/y",
yearRange: "2000:2099",
onSelect: function(e, d) {
$(this).trigger("change");
}
});
最佳答案
这是因为选项shortYearCutoff
:
The cutoff year for determining the century for a date (used in conjunction with dateFormat 'y'). Any dates entered with a year value less than or equal to the cutoff year are considered to be in the current century, while those greater than it are deemed to be in the previous century.
默认值为+10,您可以将其放大到+50等大值。
关于Jquery 日期选择器格式问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25141034/