Need help with jquery.validator.addMethod
I am trying to add a rule that will filter out profanity for a textarea on a form. I pieced together the code below and it works for the first word in the filter array, but doesn't for the rest. Any help would be appreciated.
- $(document).ready(function(){
- //custom validation rule - profanity
- $.validator.addMethod("profanity", function(value, element)
- {
- var filter = ['bad', 'word'];
- var i=0;
- for (i=0;i<=filter.length;i++)
- {
- return !RegExp('\\b' + filter[i] + '\\b', 'gi').test(value);
- }
- }
- );