Why does jQuery datapicker not constrain input when setting a date format?
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.
精彩评论