1
I am trying to make a language filter where it checks after each key pressed if there is any word not accepted.
An example, this array ['insulto1','insulto2','insulto3']
.
How do I check if any of those words exist 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.
Just what I needed! Thank you :)
– I_like_trains