Form validator plugin

Diego's picture

Writing jQuery plugins is pretty cool, and fun! Here's my second addition to my plugin repertoire, formBouncer. With just one call to formBouncer, any or all of your forms will be automatically validated before submission (where you will hopefully also run server-side validation).

All that's really needed is to add the appropriate classes to your inputs to declare what sort of validation they are subject to. The currently supported validation routines are: required, email, numeric, and confirm (password). The former three check if the input's value is present, looks like an email, or is a number. The latter routine matches the input's value with another input with a type of password.

I'll be adding the ability to define custom options, as well as more fine-grained validation routines, and ways of displaying the error message. As is, the error messages get prepended to the form and slid open.

Usage:

As always, include jquery...
  1. <script type="text/javascript" src="jquery.js"></script>
  2. // don't forget the plugin!
  3. <script type="text/javascript" src="jquery.formbouncer.js"></script>
Then, all you have to do is this...
  1. jQuery(function(){
  2.   jQuery('form').formBouncer();
  3. });

Used together with my previous plugin hinty should provide a snap on improvement to user experience when filling out forms on your site. Until HTML5 is standard of course.

Please send me any comments or suggestions! Also check out the project page on jQuery's plugins page and give it a good rating!

You can check out my plugins on github or download this plugin directly.


Visitor's picture
Would be cool to see this

Would be cool to see this plugin on a demo page :)

Submitted by Visitor (not verified) on Tue, 01/19/2010 - 05:00.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <pre>, <c>, <css>, <drupal6>, <html>, <javascript>, <mysql>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options

CAPTCHA
You're human, right?
5 + 15 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

 Check it Out!
Future of Web Apps - Miami 2010

RSS

Syndicate content

RSS, XHTML, CSS

Copyright © 2009 Grey Robot, Inc.