开发者

Why does jQuery datapicker not constrain input when setting a date format?

开发者 https://www.devze.com 2023-01-07 00:55 出处:网络
I have an input field that is being set as a date picker. When I initialize the dateFormat option it stops constraining the input and I can enter all sorts of rubbish dates in the text box. Why does t

I have an input field that is being set as a date picker. When I initialize the dateFormat option it stops constraining the input and I can enter all sorts of rubbish dates in the text box. Why does this happen? I'd like to have constrained input still work when setting a custom date format.

myTextInput.datepicker({ dateFormat: "dd-M-yy" });

If I don't set the dateFormat option then the input is c开发者_运维问答onstrained as expected.


It doesn't appear to be the custom date format itself that is breaking it. It appears that when your dateFormat includes a string representation that it isn't restricting.

$('#mydate').datepicker({ dateFormat: "yy-mm-dd" });

This seems to work correctly.

So basically the codes M, MM, D and DD break it.

0

精彩评论

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