I'm making a form and when I hit submit it will submit the form even if I leave everything blank...............what am i doing wrong??
here's the code:
<html>
<head>
<script language="JavaScript">
<!-- Hide from older browsers...
//Function to check form is filled in correctly before submitting
function CheckForm () {
var errorMsg = "";
//Check for a Subject
if (document.frmPMs.pmSubject.value==""){
errorMsg += "\n\tYou must enter a subject.";
}
//Check for a Message Body
if (document.frmPMs.pmBody.value==""){
errorMsg += "\n\tYou must enter a message body.";
}
//If there is aproblem with the form then display an error
if (errorMsg != ""){
msg = "_______________________________________________________________\n\n";
msg += "The form has not been submitted because there are problem(s) with the form.\n";
msg += "Please correct the problem(s) and re-submit the form.\n";
msg += "_______________________________________________________________\n\n";
msg += "The following field(s) need to be corrected: -\n";
errorMsg += alert(msg + errorMsg + "\n\n");
return false;
}
return true;
}
// -->
</script>
</head>
<title>PM Groups Mod by Fernan</title>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="50%" id="AutoNumber1" height="95" align = "center">
<tr>
<td width="100%" height="95" valign="top">
<form method="post" name="frmPMs" action="send_pms.asp" onSubmit="return CheckForm()">
<br>
<center><b>PM Group Mod by Fernan</b></center>
<br><p style="margin-left: 10; margin-right: 10">
Group to PM:
<select size="1" name="pmGID">
<option value="1">Forum Ådministrator</option>"
<option value="3">Forum Moderator</option>"
<option value="4">Newbie</option>"
<option value="5">Full Member</option>"
<option value="6">Advanced Member</option>"
<option value="7">Underground Member</option>"
</select><br><br>
Subject: <input type="text" name="pmSubject" size="30" maxlength="41"><br>
<br>
<textarea rows="13" name="pmbody" cols="54"></textarea><br><br>
<center><input type="Submit" value="Send" name="Submit"> <input type="reset" value="Reset" name="Reset"></center>
</form>
</p>
</td>
</tr>
</table>
<br />
<div align="center">
</div>