qualcuno sa' dirmi perche' questo validation form non funziona?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JavaScript">
function checkForm()
{
var cname, csname, cnum;
with(window.document.msgform)
{
cname = fname;
csname = sname;
cnum = nnum;
}
if(trim(cname.value) == '')
{
alert('Please enter your name');
cname.focus();
return false;
}
else if(trim(csname.value) == '')
{
alert('Please enter your surname');
csname.focus();
return false;
}
else if(trim(cnum.value) == '')
{
alert('Please enter your number');
cnum.focus();
return false;
}
else
{
cname.value = trim(cname.value);
csname.value = trim(csname.value);
cnum.value = trim(cnum.value);
return true;
}
}
/*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
return str.replace(/^\s+|\s+$/g,'');
}
</script>
<title>Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form method="GET" name="msgform" action="insert.php">
<table align="center">
<tr>
<td align="right">
First name:</p></td><td align="left"><input type="text" name="fname"></td>
</tr>
<tr>
<td align="right">
Last name:</p></td><td align="left"><input type="text" name="sname"></td>
</tr>
<tr>
<td align="right">
Number:</p></td><td align="left"><input type="text" name="num"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" onClick="checkForm(this)"></td>
</tr>
</table>
</form></br>
</body>
</html>