Hello, folks at StackOverflow.
I try to make a textarea of a web page that I'm developing check continuously if the typed text is equal to or different from a predefined phrase, according to the javascript code and jquery below:
var atualiza = function(){
var texto = $(".campo-digitacao").text();
var frase = $(".frase").text();
if (texto==frase){
console.log("TEXTO IGUAL");
} else if (texto!=frase){
console.log("TEXTO DIFERENTE");
}
console.log("escreveu");
}
$(".campo-digitacao").on('input',atualiza());
However, I only get two notifications via console ("DIFFERENT TEXT" and "wrote"), as if the 'input' event only happened once, when loading the page, instead of executing it every time the "field-typing" text changes. I tried to use other events, like 'textchange' and 'change', but I'm still in the same situation.