How to make a frequent update

Asked

Viewed 56 times

2

Hello, for example, I have the text box SENHA and CONFIRMARSENHA, and test if they are different, but I will only know when he presses a button, and I want the moment they are different (without pressing the button) I already know it.

Grateful from now on.

1 answer

5


For this you will need to use javascript to verify that the value of the fields is equal at the time the confirmation field is filled. The name of this event is onBlur.

The implementation would be in this idea:

HTML and Javascript:

    <form id="formulario">
        <input type="password" id="senha"> Senha <br/>
        <input type="password" id="confirma_senha" onBlur="verificaIgual()"> Confirma Senha <br/>
    </form>

        function verificaIgual(){
            var senha = document.getElementById('senha');
            var confirma = document.getElementById('confirma_senha');
    
            if(senha.value != confirma.value){
                alert("As senhas devem ser iguais");
            }
    
        }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.