if (fname == null || fname == "") {
Receiving an error message "uncaught syntax error:unexpected token if in line 13". The error indicates "SyntaxError: missing variable name" when using Javascript lint
function validateRegistration() {
var emailRegex = /^[A-Za-z0-9._]*\@[A-Za-z]*\.[A-Za-z]{2,5}$/;
var fname = document.form.user_firstname.value,
lname = document.form.user_lastname.value,
uname = document.form.username.value,
femail = document.form.email.value,
freemail = document.form.verify_email.value,
fpassword = document.form.password.value,
if (fname == null || fname == "") {
document.form.user_firstname.focus();
document.getElementById("errorBox")
.innerHTML = "Please enter a first name";
return false;
}
if (lname == null || lname == "") {
document.form.user_lastname.focus();
document.getElementById("errorBox")
.innerHTML = "Please enter a last name";
return false;
}
if (femail == null || femail == "") {
document.form.email.focus();
document.getElementById("errorBox")
.innerHTML = "Please enter an email";
return false;
} else if (!emailRegex.test(femail)) {
document.form.Email.focus();
document.getElementById("errorBox")
.innerHTML = "Please enter a valid email";
return false;
}
if (freemail == null || freemail == "") {
document.form.verify_email.focus();
document.getElementById("errorBox")
.innerHTML = "Please re-enter the email";
return false;
} else if (!emailRegex.test(freemail)) {
document.form.enterEmail.focus();
document.getElementById("errorBox")
.innerHTML = "Please re-enter a valid email";
return false;
}
if (fpassword == null || fpassword == "") {
document.form.password.focus();
document.getElementById("errorBox")
.innerHTML = "Please enter a password";
return false;
}
}