Running Login Validation that is causing problems. Client side 'onchange' of input id=customer email is not writting to <p> for each 'if' statement. Any help greatly appreciated.
var dbemailstr = ['heinzstapff@hotmail.com']; // emulate database email search
var newemailstr = ['gloriamarks@prodigy.net']; // emulate add to databas email addresses
var email = customeremail.value; // accessed with getElementById
var loginrequest = document.getElementById('loginrequest'); // <p> in login container
var matchemailstr = function() {
var atpos = email.indexOf("@");// test email input
var stoppos = email.lastIndexOf(".");// test email input
if (atpos == -1 || stoppos == -1) { // test email input || or symbol forces return of 'true' ?
loginrequest.innerHTML = 'Not a valid email address!';
// loginrequest.innerHTML change not made?
}
if (stoppos < atpos) { // test email input
loginrequest.innerHTML = 'Not a valid email address!';
// loginrequest.innerHTML change not made?
}
if (stoppos - atpos == 1) { // test email input
loginrequest.innerHTML = 'Not a valid email address!';
// loginrequest.innerHTML change not made?
}
if(customeremail.value == dbemailstr) { // emulate database email search
customerpasswordlist.className = 'loginlist'; // list and input appear?
customernewpasswordlist.className = 'loginlist'; // list and input appear?
loginrequest.innerHTML = 'Welcome back, please enter your password or make relevant changes!';
// loginrequest.innerHTML change not made?
}
if(customeremail.value == newemailstr) { // emulate add to databas email addresses
loginrequest.innerHTML='Welcome,You should create a password to login and register.';
// loginrequest.innerHTML change not made?
}
else{
loginrequest.innerHTML = 'Sorry, No Match Found, Press Continue to register!'; // only loginrequest.innerHTML change made?
}}
addEvent(customeremail,'change',function(){ matchemailstr(); }, true); // || or symbol return true
// uses addEvent from Chapman@about.com