csimmons.net :: Demos : garbageOUT How
BASICS:
There are 3 steps:
- You must define the totall number of fields to check, and the conditions array on the HTML page calling this script. Instructions for defining each of these elements are located in the CONDITIONS section below.
- Immediately following the definitions include this script in the HTML file using the following syntax:
<script type="text/javascript" src="myscript.js"> </SCRIPT> - Add the following to your form tag:
onSubmit = "return garbageOUT(1)"
CONDITIONS:
- NOTE: You are only changing the value of X and the array values.
- DO NOT change "CheckField" to your field's name.
- Define the arrays in the HTML page that calls this script using the following rules:
- Enter each field on a separate line.
- X is the field number. Begin with 1 and increment X by 1 on each subsequent line.
- Put true for the values you want to check based on the following key index (unless the key indicates that a number is required):
INDEX KEY:
CheckFieldX[0] = Field Name (from the form)
CheckFieldX[1] = Field Description (Used in the error message to the user)
CheckFieldX[2] = Check for Blanks
CheckFieldX[3] = Check for Email
CheckFieldX[4] = Check for Numeric Characters
CheckFieldX[5] = Check for Alpha Characters
CheckFieldX[6] = Check for Number >= array index 7. NUMBER REQUIRED!!!
CheckFieldX[7] = Number to use with array index 6. NUMBER REQUIRED!!!
- A sample array might look like:
CheckField1 = ["FN", "First Name", true, false, false, true, false, false, false]
OTHER VARIABLES:
Set the Total # of Fields to be checked with:
TotalFields = ##;
