I have a textarea, and I need to check if this textarea.value contains a string from a string array. Every onkeyup in textarea I call this script. I tried this code, but something went wrong. "@" is ok, but "apple" and "orange" is not. Please help me! Thanks!
var str = document.getElementById("messageArea").value;
var arr = ["@", "apple", "orange"];
for (var i = arr.length - 1; i >= 0; --i) {
if (str.indexOf(arr[i]) != -1) {
alert('contains');
} else {
alert('not contains');
}
}