hi again! i ran into a tutorial for javascript regarding: Regxp, then i came up with this code
} else if(name = /^ZPR\[0-9]$/) {
hideAllErrors();
document.getElementById("nameError").style.display = "inline";
document.getElementById("name").select();
return false;
but it doesnt work, can somebody please guide me accordingly?
below is my current validation.js
function checkForm() {
name = document.getElementById("name").value;
email = document.getElementById("email").value;
if (name == "") {
hideAllErrors();
document.getElementById("nameError").style.display = "inline";
document.getElementById("name").select();
return false;
} else if (email == "") {
hideAllErrors();
document.getElementById("emailError").style.display = "inline";
document.getElementById("email").select();
return false;
} else if (email.indexOf("@") < 1) { // must contain @, and it must not be the first character
hideAllErrors();
document.getElementById("emailError").style.display = "inline";
document.getElementById("email").select();
return false;
} else if (email.lastIndexOf(".") <= email.indexOf("@")) { // last dot must be after the @
hideAllErrors();
document.getElementById("emailError").style.display = "inline";
document.getElementById("email").select();
return false;
} else if (email.indexOf("@") == email.length) { // @ must not be the last character
hideAllErrors();
document.getElementById("emailError").style.display = "inline";
document.getElementById("email").select();
return false;
} else if (email.indexOf("..") >=0) { // two periods in a row is not valid
hideAllErrors();
document.getElementById("emailError").style.display = "inline";
document.getElementById("email").select();
return false;
} else if (email.indexOf(".") == email.length) { // . must not be the last character
hideAllErrors();
document.getElementById("emailError").style.display = "inline";
document.getElementById("email").select();
return false;
}
return true;
}
function hideAllErrors() {
document.getElementById("nameError").style.display = "none"
document.getElementById("emailError").style.display = "none"
}