John F. Dumas Vulcan Ware

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>

   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))

<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()">

View Source   DownLoad