This is my java code, all the id's are the ids of divs on the page. They are all labeled respectiviley. It takes the input of the form. There are six possble errors that can occur which are, the emails dont match. First name contains characters other than letters, last name contains characters other than letters, passwords dont match, password is less than six characters, and the p number has an error.
var emailError = 0
var first_nameError = 0
var last_nameError = 0
var pError = 0
var passwordError = 0
var passwordError2 = 0
function hideDiv() {
if (document.getElementById) {
document.getElementById('password2_error_wrapper').style.display = 'none';
document.getElementById('password_error_wrapper').style.display = 'none';
document.getElementById('email_error_wrapper').style.display = 'none';
document.getElementById('p_error_wrapper').style.display = 'none';
document.getElementById('f_error_wrapper').style.display = 'none';
document.getElementById('l_error_wrapper').style.display = 'none';
}
}
function showEmailError() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('email_error_wrapper').style.display = 'block';
}
}
function showFirst_nameError() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('f_error_wrapper').style.display = 'block';
}
}
function showLast_nameError() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('l_error_wrapper').style.display = 'block';
}
}
function showPError() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('p_error_wrapper').style.display = 'block';
}
}
function showPasswordError() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('password_error_wrapper').style.display = 'block';
}
}
function showPassword2Error() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('password2_error_wrapper').style.display = 'block';
}
}
function validateForm() {
validateFirst_name(form.first_name.value)
validateLast_name(form.last_name.value)
validatePlate_number(form.p_number.value)
validateState(form.state.value)
validateEmail(form.email.value)
validatePassword(form.password.value)
if (emailError = 1) { showEmailError(); return false }
if (first_nameError = 1) { showFirst_nameError(); return false }
if (last_nameError = 1) { showLast_nameError(); return false }
if (pError = 1) { showPError(); return false }
if (passwordError = 1) { showPasswordError(); return false }
if (passwordError2 = 1) { showPassword2Error(); return false }
else { return true }
}
function validateFirst_name(field) {
p = field.compile("[^A-Za-z]");
if (p.matcher(field).find()) {
first_nameError = 1
}
}
function validateLast_name(field) {
p = field.compile("[^A-Za-z]");
if (p.matcher(field).find()) {
last_nameError = 1
}
}
function validatePlate_number(field) {
pp = field.delete("^a-zA-Z0-9")
if (pp = ""){
pError = 1;
}
else if (pp.length < 3){
pError = 1;
}
}
function validateEmail(field) {
email1 = field.toLowerCase()
temp_email = form.retype_email.value
email2 = temp_email.toLowerCase()
if (email != email2){ emailError = 1;}
return ""
}
function validatePassword(field) {
password1 = field
password2 = form.retype_password.value
if (field.length < 6){
passwordError = 1;
}
if (password1 != password2 ){
passwordError2 = 1;
}
return ""
}
It is not catching anny errors and just send the script right through. What is wrong with the code?