Table of Contents
|
All Slides
|
Link List
|
Examples
|
CSCI E-12
<< previous
|
next >>
Form Control
Validate form input using the
onsubmit
event handler.
Example 8.5
Example 8.5 Source:
<form action="http://minerva.dce.harvard.edu/cgi-bin/echo.cgi" method="get" onsubmit="return Validate(this)" > <div>Enter your name: <input type="text" name="YourName" /><br/> <input type="submit" value="Submit Information" /></div> </form>
In
script
element (within
head
element):
function Validate(thisform) { if(thisform.YourName.value == null || thisform.YourName.value == "") { alert("Please enter your name!"); thisform.YourName.focus(); return false; } }
Example 8.5 Demonstrated
Table of Contents
|
All Slides
|
Link List
|
Examples
|
CSCI E-12
<< previous
|
next >>