I have a simple form with four fields. The validation code for these fields are not working properly in both IE and firefox.I have given the code below.Please tell me whats the problem.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.content {
overflow: auto;
width: 400px;
height:200px;
}
-->
</style>
<script language="javascript" type="text/javascript" >
function checkvals(){
if (document.myFRM.name.value=="NULL"){
alert("Please Enter the Name field.");
document.myFRM.name.focus();
return false;
} else if (document.myFRM.mobile.value=="NULL"){
alert("Please Enter a valid Mobile Number.");
document.myFRM.mobile.focus();
return false;
} else if (document.myFRM.email.value=="NULL") {
alert("Please enter a valid email address.");
document.myFRM.email.focus();
return false;
} else if (document.myFRM.message.value=="NULL") {
alert("Please Enter the Message Field.");
document.myFRM.message.focus();
return false;
} else {
return true;
}
}
</script>
</head>
<body>
<table width="720" height="585" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th scope="col"><form method="post" name="myFRM" id="myFRM" onSubmit="return checkvals()" action="">
<table width="553" height="478" border="0" cellpadding="0" cellspacing="0">
<tr>
<th height="52" colspan="4" scope="col"> </th>
</tr>
<tr>
<th width="85" height="41" scope="row"> </th>
<td width="136"><div align="right">Name:</div></td>
<td width="10"> </td>
<td width="322"><input name="name" type="text" id="name"></td>
</tr>
<tr>
<th height="37" scope="row"> </th>
<td><div align="right">Mobile No.:</div></td>
<td> </td>
<td><input name="mobile" type="text" id="mobile"></td>
</tr>
<tr>
<th height="37" scope="row"> </th>
<td><div align="right">E-Mail:</div></td>
<td> </td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<th height="221" scope="row"> </th>
<td><div align="right" class="style1">Message:</div></td>
<td> </td>
<td><textarea name="message" class="content" id="message"></textarea></td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form></th>
</tr>
</table>
</body>
</html>
Comment