Wednesday, January 30th, 2008p>JÃ¶rn Zaefferer went absolutely feature crazy when he decided to update his jQuery Validation plugin. Update is putting it mildly with “overhaul” coming immediately to mind.
Here are some of the cool new features added in:
- AJAX-captcha validation example (based on http://psyrens.com/captcha/)
- Support for “remote” ajax-validation. In other words: Remote validation is now possible and very easy to use.
- Added highlight and unhighlight options, by default toggles errorClass on element, allows custom highlighting
- Added valid() plugin method for easy programmatic checking of forms and fields without the need to use the validator API
- Added rules() plguin method to read and write rules for an element (currently read only)
- Replaced regex for email method, thanks to the contribution by Scott Gonzalez, see http://projects.scottsplayground.com/email_address_validation/
- Restructured event architecture to rely solely on delegation, both improving performance, and ease-of-use for the developer (requires jquery.delegate.js)
- Added feature to merge min + max into and range and minlength + maxlength into rangelength
- Added support for dynamic rule parameters, allowing to specify a function as a parameter eg. for minlength, called when validating the element
- Allow to specify null or an empty string as a message to display nothing
- Rules overhaul: Now supports combination of rules-option, metadata, classes (new) and attributes (new), see rules() for details
- Added remember-the-milk-demo (thanks RTM team for the permission!)
- Added marketo-demo (thanks Glen Lipka!)
One of the best features of this release is the remote validation via Ajax. This is extremely easy to implement with the code being as simple as this:
If you enter an email address, the validation plugin sends a request to the server with a parameter â€œemailâ€ and the value you entered. The server-side code can do it’s magic and send back the appropriate response based on the user input.
Adding client-side validation to a form can significantly improve the usability of that form, making it much easier for users to fill them out successfully. But pure client-side validation has severe limits where necessary information is available only on the server. Ajax helps to bridge the gap, but synchronizing validation on form submit isnâ€™t exactly an easy task. The validation plugin makes it as simple as pure client-side validation. All you need to do is to specify a rule â€œremoteâ€ for a field and provide a parameter that points to a server-side resource that handles the validation.
Posted by Rey Bango at 6:00 am