Useful HTML

The "OnSubmit" event

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>
 
/home/dodgydevil/wiki.zendfusion.com/data/pages/scripts/html.txt · Last modified: 2009/03/10 06:38 by bosbaba
[unknown button type]
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Zend Fusion