I find solution, to ban some words if they are entered in input field. The problem is that i need ban them only when somebody use them as single word, not when are entered with more words.
Example:
If %bannedword% was entered then ERROR must show up, but if somebody write
" %bannedword% wordnotbanned "
all must be marked as correct input fill, without any ERROR.
What i must do to everything works fine?
Here is the jQuery
$('#submit').click(function() {
var bannedWords = ["black", "white"],
regex = new RegExp('\\b' + bannedWords.join("\\b|\\b") + '\\b', 'i');
var zalvalid = !regex.test($('#zalmie').val().toLowerCase());
if(!zalvalid) {
$('#zwynik').addClass("hover").html('<strong>ERROR:</strong>');
$('#zalmie').focus();
return false;
} else {
$('#zwynik').addClass("hover").html('<strong>NICE ONE!</strong>');
}
});
and here is the Fiddle: http://jsfiddle.net/p16954wc/