Contents Home Page Previous Page Next Page

More Forms Validation
- Instructions

This script, although long, is easily used. Just paste the entire script into the <HEAD> area of your page as the first step. All the messages are customized in the hidden form element where you also select the validation requirement. You can mix the required element with any of the other elements. This code is completely portable and can be used with any form by just changing the onclick element count and adding your hidden elements appropriately.

Setting up the fields

1) To set a required field use your existing field name and add an r_ to the beginning of the field name and create a hidden element.
EXAMPLE:
<input type="text" name="your_fieldname">
<input type="hidden" name="r_your_fieldname" value="Your required error message goes here">

2) To set an integer field use your existing field name and add an i_ to the beginning of the field name and create a hidden element.
EXAMPLE:
<input type="text" name="your_fieldname">
<input type="hidden" name="i_your_fieldname" value="Your integer error message goes here">

3) To set a date field use your existing field name and add a d_ to the beginning of the field name and create a hidden element. This date field only accepts the format MM/DD/YY or M/D/YY.
EXAMPLE:
<input type="text" name="your_fieldname">
<input type="hidden" name="d_your_fieldname" value="Your date error message goes here">

Initialising the script

You MUST use the type="button" NOT type="submit" for your ACTION button, the javascript sends the submit for you. The onclick command function is check(form,x) where x equals the number of form elements on the page including all hidden elements.
EXAMPLE:
<input type=button Value="Button Message Here" onclick="check(form,10)">


Script by Art Lubin / Artswork