Hi, Can some one help me? I dont know why my checkEmail function is not working, it gives errors.
Code:
<html>
<head><title>Registration Details</title>
<SCRIPT LANGUAGE="JavaScript">
/**
function processForm1() {
var form1 = document.formOne;
if (form1.firstname.value==""){
alert("you must fill in your first name")
formOne.firstname.focus();
}
else if (form1.lastname.value==""){
alert("you must fill in your lastname")
formOne.lastname.focus();
}
else if (form1.postcode.value==""){
alert("you must fill in your postcode")
formOne.postcode.focus();
}
else if (form1.dateofbirth.value==""){
alert("you must fill in your DOB")
formOne.dateofbirth.focus();
}
else if (form1.contactphonenumber.value==""){
alert("you must fill in your phone number")
formOne.contactphonenumber.focus();
}
else if (form1.emailaddress.value==""){
alert("you must fill in your email address")
formOne.emailaddress.focus();
}
else {
controlForm = parent.frame2.document.controlForm
controlForm.firstname.value=form1.firstname.value
controlForm.lastname.value=form1.lastname.value
controlForm.address.value=form1.address.value
controlForm.city.value=form1.city.value
controlForm.county.value=form1.county.value
controlForm.postcode.value=form1.postcode.value
controlForm.country.value=form1.country.value
controlForm.contactphonenumber.value=form1.contactphonenumber.value
controlForm.dateofbirth.value=form1.dateofbirth.value
controlForm.emailaddress.value=form1.emailaddress.value
controlForm.mypassword.value=form1.mypassword.value
location.href="login.html"
}
}**/
function checkEmail() {
var emailFilter=/^/w+([/.-]?/w+)*@;
if(emailFilter.test(document.form1.emailaddress))
return true
else{
alert(“invalid email address”)
formOne.emailaddress.focus();
}
}
</script>
</head>
<body>
<form method="GET" action="http://localhost:8081/controlform.html" NAME="formOne" >
<center>
<h1>Registration Details</h1>
<br><br>
First Name <input type="text" name="firstname" value=""><br><br>
Last Name <input type="text" name="lastname" value=""><br><br>
Address <input type="text" name="address" value=""><br><br>
City <input type="text" name="city" value=""><br><br>
County (optional) <input type="text" name="county" value=""><br><br>
Post Code <input type="text" name="postcode" value=""><br><br>
Country <input type="text" name="country" value=""><br><br>
Contact Phone Number <input type="text" name="contactphonenumber" value=""><br><br>
Date of Birth <input type="text" name="dateofbirth" value=""><br><br>
Email Address <input type="text" name="emailaddress" value=""><br><br>
Password (minimum 6 characters) <INPUT TYPE=PASSWORD NAME="mypassword"><br><br>
<input type="BUTTON" NAME="Submit" value="--SUBMIT--" onClick="checkEmail()">
</center>
</form>
</body>
</html>
Comment