I am trying to validate a form on an asp page before it is submitted to the database but it is not working. The code is in an external javascript page and looks like this –
<!–
function check()
{
x=document.details;
player=x.player;
position=x.position;
club=x.club;
value=x.val;
ok=”true”
if (player.length<1)
{
alert(“Must enter Player’s Name”)
ok=”false”
}
if (position.length<1)
{
alert(“Invalid position”)
ok=”false”
}
if (club.length<1)
{
alert(“Invalid club name”)
ok=”false”
}
if (val.length<1)
{
alert(“Must be entered to one decimal place eg 3.1”)
ok=”false”
}
}
// –>
the page that calls the function looks like this :-
<html>
<head>
<script src=”useful.js”>
</script>
</head>
<body><form name=”details” method=”post” enctype=”text/plain” action=”demo_add.asp” onsubmit=”return check()”>
<table>
<tr>
<td>Player Name:</td>
<td><input name=”player”></td>
</tr><tr>
<td>Position:</td>
<td><input name=”position”></td>
</tr><tr>
<td>Club:</td>
<td><input name=”club”></td>
</tr><tr>
<td>Value:</td>
<td><input name=”val”></td>
</tr>
</table>
<br /><br />
<input type=”submit” value=”Add New”>
<input type=”reset” value=”Clear”>
</form>
</body>
</html>
If I leave the form blank, I get the following error :-
Error Type:
Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression.
/demo_add.asp, line 12
Does anyone have any ideas?? The function works because it validates another form but for some reason it will not execute the function before it tries submitting the data to the database.