lundi 17 mai 2021

How do you make an if-else statement permanent and not be activated just once?

function charCheck(str) {
    if (str.length > 20 || str.length < 4 || str.indexOf(' ') >= 0) {
        document.getElementById("error1").innerHTML = ("Username must be between 4-20 characters long and must have no spaces.")
    }
    else {
        document.getElementById("error1").style.display = "none";
    }
}

My code only shows the message only once after I trigger it, instead of being displayed and hid multiple times.

When I type in an insufficient username the first time, I receive the intended error message. But, when I rewrite the username, the message isn't displayed. https://i.stack.imgur.com/cnhXh.png

How do I fix this?

Aucun commentaire:

Enregistrer un commentaire