3
I did the following function:
function verifica(){
var csenha = document.getElementById("csenha").value;
var csenha2 = document.getElementById("csenha2").value;
if(csenha != csenha2){
document.getElementById("csenha2").setCustomValidity("As senhas são diferentes.");
csenha2.setCustomValidity('');
return false;
}
}
It is to confirm the password, and it works, if they are different it returns false to the form and prevents Ubmit, but even when I change them to be equal, keeps entering the condition of if and warning that they are different. I want to know how to make it stop happening. HTML is like this:
<label for="senha"><b>Senha</b></label>
<input type="password" placeholder="Insira sua senha." id="csenha" required>
<label for="senha-repeat"><b>Repita a senha</b></label>
<input type="password" placeholder="Insira sua senha novamente." id="csenha2" required>
Function call:
<button type="submit" onclick="return verifica()" class="btn btn-success btn-lg btn-block" id="signin">Cadastrar</button>
I did it the way you said, and now he locks the Ubmit until the passwords match, but the first line warning no longer appears.
– ErickGermani
Ask the question how you are calling the check function().
– Sam
All right, it’s done.
– ErickGermani
I changed the code again... no need to
else
.– Sam