In the jQuery Validation plugin there are a couple of methods that do the same thing, but for different locales, for example dateISO
and dateDE
, that both validate date formatting. How do I combine these so that the input element accepts either?
Let's say I have an <input type="text" name="dateInput" id="dateInput" />
in my form, and I want to allow users to enter only dates in this field. However, I want to allow for several different date formats - for example, the user should be able to enter either an ISO date or a date formatted accoding to German date rules.
If I do
rules: { dateInput: { required: true, dateISO: true, dateDE: true } }
the form will never be valid, as both date formats will be required and that requirement can never be fulfilled. Is there a way to combine these as an "or" instead of as an "and", without having to write my own validation method?
And if I do have to write my own, how do I make it as generic as possible?