return is not working

Adityaniceboy89

Solid State Member
Messages
10
Location
Mauritius
Hi everyone, I have a code to validate a form but the return function is not working. so here is a snippet of the code

<html>
<head>
<title>Satisfaction Form</title>
<script>
function Check()
{
var x=document.forms["satisfaction"] ["txtName"].value;

if (x==null || x=="")
{
alert("Field 'Your Name' should not be empty!");
return false;
}
}
</script>
</head>
<body>
<form name="satisfaction" action="satisfaction.php" method="post" onsubmit="Check()">
<table border=1>
<tr>
<td>Your Name</td>
<td><input type=text name="txtName" /></td>
</tr>
<tr>
<td align="center" colspan=2> <input type=submit name="submit" value="submit"/>
<input type=reset name="reset" value="reset"/></td>
</tr>
</table>
</form>
</body>
</html>

Anyone can find the error for me?
 
Back
Top Bottom