How would I use the jqueryUI "datepicker" if I want my input field to allow non-dates (or invalid dates)?
I have a server-side script which can handle a normal date as input, or an asterisk to mean "latest date available" (amongst a few other special codes).
It would be nice to have a popup datepicker in my HTML form, but only when needed.
How can I use the jqueryUI datepicker to choose a specific date (for example, by clicking on a datepicker icon), while also allowing the user to enter one of our special codes as a "fake date"?
Thanks!
You can use the constrainInput
option to allow all characters to be entered into the input
:
$("#someElem").datepicker({
constrainInput: false
});
See this working example. The first input
will allow any characters to be typed. The second input
will only allow the defaults allowed by the datepicker
widget (which I think is just numbers and the /
character).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With