I'm doing form validation with javascript the last if statement is suppose to print out the error, it check for an empty variable and displays the result. The first part works as it should, but the else part displays red box instead of green
//Printing the errors
if(error){
document.getElementById("errors").className = "alert alert-danger";
document.getElementById("errors").innerHTML = error;
}
else{
//if(error == null){
document.getElementById("errors").className = "alert alert-success";
document.getElementById("errors").innerHTML = "Form Values Successfully Validated";
}
//Debugging
console.log(error);
//return error;
}
Aucun commentaire:
Enregistrer un commentaire