Sponsered Links
Categories
Sponsered Links

JavaScript Form validation Example

 

 This is a simple JavaScript Form validation Example.

 <html>

<head>
<script type="text/javascript">
function validate_form(){
var name = form1.name.value;
var email = form1.email.value;
if (name == ""){
alert("Name Required");
form1.name.focus();
return false;
}
if (email == ""){
alert("Email Required");
form1.email.focus();
return false;
}
return true;
}
</script>
</head>
 
<body>
<form action="" onsubmit="return validate_form()" method="post" name="form1">
<table bgcolor="#ajdshs" align="center" border="1">
<tr>
<td>Name: </td>
<td>
<input type="text" name="name" size="30">
</td>
</tr>
<tr>
<td>Email: </td>
<td>
<input type="text" name="email" size="30">
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Submit">
</td>
</tr>
</table>
</form>
</body>
</html>

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved