How to make a frequent update

2
Hello, for example, I have the textbox SENHA and CONFIRMARSENHA , and testo if they are different, but I will only know when it presses a button, and I want it at the moment they are different ( without having to press the button) I already know that.

Thank you in advance.

    
asked by anonymous 30.04.2015 / 23:07

1 answer

5

For this you will need to use javascript to check if the value of the fields is the same when the confirmation field is filled in. 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");
            }
    
        }
    
30.04.2015 / 23:14