can anyone figure out whats wrong with my code! I want a password validation in the third if statement. but it seems that Im just stuck with my 2nd If statement! I've been on it for hours.. dont know what went wrong! help PLS!and by the way im using onkeyup event.
function validateTextbox(){
var user = document.getElementById("username");
var pass = document.getElementById('password');
var cpass = document.getElementById('cpassword');
var message = document.getElementById('confirmMessage');
var goodColor = "#66cc66";
var badColor = "#ff6666";
//(first if statement) if its false its gonna output
//Username must be 6 characters if true its gonna
//proceed to 2nd statement
if(user.value.length >= 6){
//(2nd if statement) if its false its gonna output
//password must be 8 characters if true its gonna
//proceed to 3rd statement
if(pass.value.length >= 8){
//And it does not validate password matched
//I dont know what went wrong
if(pass.value == cpass.value){
cpass.style.backgroundColor = badColor;
message.style.color = goodColor;
message.innerHTML = "Passwords match"
}
else{
cpass.style.backgroundColor = goodColor;
message.style.color = badColor;
message.innerHTML = "Passwords does not match!"
}
}
else{
pass.style.backgroundColor = badColor;
message.style.color = badColor;
message.innerHTML = "Password must be 8 characters"
}
}
else{
user.style.backgroundColor = badColor;
message.style.color = badColor;
message.innerHTML = "Username must be 6 characters"
}}
Aucun commentaire:
Enregistrer un commentaire