Here is an example for form validation with javascript
<html>
<head>
<title>From Validation</title>
<script language="javascript">
function chkForm(form)
{
if(form.cname.value == ""){ alert("Enter Name"); form.cname.focus(); return false; }
if(form.age.value == "0"){ alert("Select Age Level"); return false; }
}
</script>
</head>
<body>
<div align="center">
<form name="test" action="some_page.php" method="post" onsubmit="return chkForm(this);">
<table border="0" cellpadding="0" cellspacing="0" width="100%" id="table1">
<tr>
<td width="139">Name</td>
<td><input type="text" name="cname" size="20"></td>
</tr>
<tr>
<td width="139">Age</td>
<td><select size="1" name="age">
<option selected value="0">Select</option>
<option value="below 18">below 18</option>
<option value="18+">18+</option>
</select></td>
</tr>
<tr>
<td width="139"> </td>
<td><input type="submit" value="Submit" name="B1"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
Older posts
Radio button validation:
http://phpbeginners.blogspot.com/2008/06/radio-button-validation-in-javascript.html
checkbox validation:
http://phpbeginners.blogspot.com/2008/05/checkbox-validation-in-javascirpt.html
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment