How can I specify a custom date formate to be validated with the Validation Plugin for jQuery?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
Here is an example for a new validation method that will validate almost any date format, including:
Then, when you pass the value to the php you can convert it with strtotime
Here is how to add the method:
Then you add the new filter with:
;
Jon, you have some syntax errors, see below, this worked for me.
nickf's answer is good, but note that the validation plug-in already includes validators for several other date formats, in the additional-methods.js file. Before you write your own, make sure that someone hasn't already done it.
@blasteralfred:
I got following rule validating correct date for me (DD MM YYYY)
);
For DD/MM/YYYY
);
This will not validate 01 13 2017 and 01/13/2017.
And also does not validate 50 12 2017 and 50/12/2017.
Here's a specific code sample which worked for me recently:
I should note that this actually replaces the built-in date validation routine, though I couldn't see that this should cause an issue with the current plugin.
I then applied this to the form using:
Is Easy, Example: Valid for HTML5 automatic type="date".