hey peoples.
I have a simple form (currently two fields) which is then passed to an ASP
page thats stores the data in a dbase
I have an error checking script which I can't get to work. the script is :
<script language="JavaScript">
<!-- Hide from older browsers...
//Function to check form is filled in correctly before submitting
function CheckForm () {
//Intialise variables
var errorMsg = "";
var errorMsgLong = "";
//Check for a name
if (document.frmregnewuser.name.value == ""){
errorMsg += "\n\tName \t\t- Enter your Name";
}
//Check for comments
if (document.frmregnewuser.e-mail.value == ""){
errorMsg += "\n\tComments \t- Enter a valid email address";
}
//If there is aproblem with the form then display an error
if ((errorMsg != "") || (errorMsgLong != "")){
msg =
"_________________________________________________ __________________\n\n";
msg += "Your registration could not be completed 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" + errorMsgLong);
return false;
}
return true;
}
// -->
</script>
I have the submit button and the following code in the form
onsubmit = "return checkform ();"
but it doesn't run the check...can anyone see anything obvious??
many thanks