I'm trying to make a language filter where it checks after every key pressed if there is any unacceptable word.
An example, this array ['insulto1','insulto2','insulto3']
.
How do I check if any of those words exists in what the user is typing?
This is the code
$("#adicionar_coment").keyup(function(e){
var nome = $("#nome_user").html();
var code = e.keyCode || e.which;
var html = $("#adicionar_coment").val();
var array = [Array a cima dito]
for(var i = 0; i < array.length; i++){
if(html.indexOf(array[i]) >= 0){
erro=1;
}else{
erro=0;
}
}
});
With the above code, it only gives error when it is equal to the last word of the array.