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
Check out: jQuery Masked Input Plugin
You can create your own custom validation method using the
addMethod
function. Say you wanted to validate "dd/mm/yyyy":And then on your form add:
This is me combining/modifying previous posts to achieve my desired result:
Add Date validation after your validation config. I.e. after calling the $(form).validate({ ... }) method.
Finally, the main isDate Javascript function modified for UK Date Format
I personally use the very good http://www.datejs.com/ library.
Docco here: http://code.google.com/p/datejs/wiki/APIDocumentation
You can use the following to get your Australian format and will validate the leap day 29/02/2012 and not 29/02/2011:
I also use the masked input plugin to standardise the data http://digitalbush.com/projects/masked-input-plugin/
you can input like
yyyy-mm-dd
alsoyyyy/mm/dd
but can't judge the the size of the month sometime Feb just 28 or 29 days.