jQuery Validation Plugin v1.2 Updated

Written by on January 30th, 2008 in Ajax News.

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:

LANGUAGE:

    <input id="email" class="required email" remote="emails.php" maxlength="40" name="email" />

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.

To see the plugin in action, Jörn has created some demos using styling from Marketo.com and Remember the Milk. You can see some screenshots below.

Source: Ajaxian
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/225840258/jquery-validation-plugin-v12-updated

Comments are closed.



Site Navigation