John F. Dumas Vulcan Ware
_blank_
form.js

Client side form element validation isn't particularly entertaining under the best of circumstances but it's less unpleasant with a good library at your disposal. Here's a demo showing form.js's full capabilities and here's a short example showing typical usage:

<script src="form.js"></script>

<script>
   function doSubmit()
   {
      var table = [
         {
            field: "an_integer",
            label: "An Integer",
            valid: Form.txtIsInteger
         },
         {
            field: "an_email",
            label: "An Email",
            valid: Form.txtIsEmail
         }
      ];

      var f = document.forms['form'];

      if(Form.fieldsCheck(f, table))
         alert("Ok");
   }
</script>

<form name="form">
 An Integer: <input type="text" name="an_integer"><br>
 An Email Address: <input type="text" name="an_email"><br>
 <input type="button" value="Submit Form" onClick="doSubmit()">
</form>

View Source   DownLoad