I have a textarea inside a form.
Before the form is submitted, the textarea is validated and checked so it is not empty, not over 2000 characters, not contain forbid
var bad_words = new Array('word1', 'word2'); var user_words = document.getElementById('textarea').split(/\W+/); for( var i in bad_words) { if( user_words.indexOf( bad_words[i] ) != -1 ) { alert( 'The textarea has bad word!'); break; } }