libjsform | manual | examples | download | browser_notes | license
This javascript form library allows you to easily add basic client-side validation routines to an existing HTML form by simply adding attributes to the form elements you want to validate.
You can add your own validation routines and use them just like the built-in routines.
The library comes with an English module for generating grammatically correct error messages.
Notice the added required=true tags and also ignore="-select-" in the form source below. The "{required:validaterequired}" phrase in the javascript portion of the example tells the library to look for required=true attributes in the HTML form elements in order to know which elements are required.
<script language="JavaScript"> <!-- function validate_example1(theform) { var errors = check(theform, {required:validaterequired}); if( errors.length > 0 ) { alert("The form is not complete! Please fill in all required fields."); return false; } return true; } --> </script> <form onsubmit="return validate_example1(this);"> Your name: <select required=true ignore="-select-"> <option>-select-</option> <option>Tarzan</option> <option>Jane</option> </select> <br> <INPUT TYPE="checkbox" required=true>I promise to bring some chocolate mousse!<BR> <INPUT TYPE="submit"><BR> </form>
Copyright (C) 2009 Jonathan Buhacoff