You can use the “onSubmit()” event handler in the form tag to do some form validation!
Place the “onSubmit()” event handler in the “Form” tag
<FORM ACTION="formdata.php" NAME="testform" onSubmit="return TestDataCheck()" >
for example you can use it like this
<SCRIPT TYPE="text/javascript"> <!-- // check that they entered an amount tested, an amount passed, // and that they didn't pass units than they more than tested function TestDataCheck() { var qtytested = parseInt(document.testform.qtytested.value); var qtypassed = parseInt(document.testform.qtypassed.value); var returnval; if ( (qtytested >= 1) && (qtypassed >= 0) && (qtytested >= qtypassed)) returnval = true; else { alert("must enter the quantity tested and that amount or fewer for quantity passed"); returnval = false; } return returnval; } // --> </SCRIPT> <FORM ACTION="formdata.php" NAME="testform" onSubmit="return TestDataCheck()" > units tested: <INPUT NAME="qtytested" SIZE=3><BR> units passed: <INPUT NAME="qtypassed" SIZE=3><P> <INPUT TYPE=SUBMIT VALUE="Submit"> </FORM>