[jQuery] Re: [validate] how to test text against a bad word list?
return !/bad|word|must|not|match/.test(value); Jörn On Mon, Sep 22, 2008 at 1:25 PM, tobaco [EMAIL PROTECTED] wrote: hi, i'm using the excellent validate-plugin and it works like a charm. now i want to test the text in a textarea against a list of bad words. how must be the syntax of the custom validation rule? i'm very bad in regex … thanks in advance, tobaco
[jQuery] Re: [validate] how to test text against a bad word list?
uh, that was fast! thx, i will give it a try. aehm, is it possible to put the bad word in an array and test this. On 22 Sep., 13:31, Jörn Zaefferer [EMAIL PROTECTED] wrote: return !/bad|word|must|not|match/.test(value); Jörn On Mon, Sep 22, 2008 at 1:25 PM, tobaco [EMAIL PROTECTED] wrote: hi, i'm using the excellent validate-plugin and it works like a charm. now i want to test the text in a textarea against a list of bad words. how must be the syntax of the custom validation rule? i'm very bad in regex … thanks in advance, tobaco
[jQuery] Re: [validate] how to test text against a bad word list?
Sure. You can create a regexes on the fly with new RegExp(bla) and use that instead of the inline regex /bla|blu/. Jörn On Mon, Sep 22, 2008 at 1:37 PM, tobaco [EMAIL PROTECTED] wrote: uh, that was fast! thx, i will give it a try. aehm, is it possible to put the bad word in an array and test this. On 22 Sep., 13:31, Jörn Zaefferer [EMAIL PROTECTED] wrote: return !/bad|word|must|not|match/.test(value); Jörn On Mon, Sep 22, 2008 at 1:25 PM, tobaco [EMAIL PROTECTED] wrote: hi, i'm using the excellent validate-plugin and it works like a charm. now i want to test the text in a textarea against a list of bad words. how must be the syntax of the custom validation rule? i'm very bad in regex … thanks in advance, tobaco
[jQuery] Re: [validate] how to test text against a bad word list?
hm, i tried it this way, var badwordlist = new Array(Nice Site, Good Work, xxx, url=http, drugs, aciphex, nude); jQuery.validator.addMethod(badWord, function(value) { return new RegExp('!/' + badwordlist.join('|') + '/').test(value); }, Verdacht auf Spam-Versuch. Bitte passen Sie Ihren Kommentar an.); but now it works in the opposite way. the textarea is now only valid, if i enter one of the bad words … this return !/nice site|good work|xxx|aciphex|url=http|nude/.test(value); works fine. On 22 Sep., 14:32, Jörn Zaefferer [EMAIL PROTECTED] wrote: Sure. You can create a regexes on the fly with new RegExp(bla) and use that instead of the inline regex /bla|blu/. Jörn On Mon, Sep 22, 2008 at 1:37 PM, tobaco [EMAIL PROTECTED] wrote: uh, that was fast! thx, i will give it a try. aehm, is it possible to put the bad word in an array and test this. On 22 Sep., 13:31, Jörn Zaefferer [EMAIL PROTECTED] wrote: return !/bad|word|must|not|match/.test(value); Jörn On Mon, Sep 22, 2008 at 1:25 PM, tobaco [EMAIL PROTECTED] wrote: hi, i'm using the excellent validate-plugin and it works like a charm. now i want to test the text in a textarea against a list of bad words. how must be the syntax of the custom validation rule? i'm very bad in regex … thanks in advance, tobaco
[jQuery] Re: [validate] how to test text against a bad word list?
Try this: return !new RegExp(badwordlist.join('|')).test(value); Jörn On Mon, Sep 22, 2008 at 3:50 PM, tobaco [EMAIL PROTECTED] wrote: hm, i tried it this way, var badwordlist = new Array(Nice Site, Good Work, xxx, url=http, drugs, aciphex, nude); jQuery.validator.addMethod(badWord, function(value) { return new RegExp('!/' + badwordlist.join('|') + '/').test(value); }, Verdacht auf Spam-Versuch. Bitte passen Sie Ihren Kommentar an.); but now it works in the opposite way. the textarea is now only valid, if i enter one of the bad words … this return !/nice site|good work|xxx|aciphex|url=http|nude/.test(value); works fine. On 22 Sep., 14:32, Jörn Zaefferer [EMAIL PROTECTED] wrote: Sure. You can create a regexes on the fly with new RegExp(bla) and use that instead of the inline regex /bla|blu/. Jörn On Mon, Sep 22, 2008 at 1:37 PM, tobaco [EMAIL PROTECTED] wrote: uh, that was fast! thx, i will give it a try. aehm, is it possible to put the bad word in an array and test this. On 22 Sep., 13:31, Jörn Zaefferer [EMAIL PROTECTED] wrote: return !/bad|word|must|not|match/.test(value); Jörn On Mon, Sep 22, 2008 at 1:25 PM, tobaco [EMAIL PROTECTED] wrote: hi, i'm using the excellent validate-plugin and it works like a charm. now i want to test the text in a textarea against a list of bad words. how must be the syntax of the custom validation rule? i'm very bad in regex … thanks in advance, tobaco
[jQuery] Re: [validate] how to test text against a bad word list?
doh! (http://www.fortunecity.com/lavendar/poitier/135/doh.wav) (hätte ich auch selber drauf kommen können …) thanks! works great! On 22 Sep., 16:03, Jörn Zaefferer [EMAIL PROTECTED] wrote: Try this: return !new RegExp(badwordlist.join('|')).test(value); Jörn On Mon, Sep 22, 2008 at 3:50 PM, tobaco [EMAIL PROTECTED] wrote: hm, i tried it this way, var badwordlist = new Array(Nice Site, Good Work, xxx, url=http, drugs, aciphex, nude); jQuery.validator.addMethod(badWord, function(value) { return new RegExp('!/' + badwordlist.join('|') + '/').test(value); }, Verdacht auf Spam-Versuch. Bitte passen Sie Ihren Kommentar an.); but now it works in the opposite way. the textarea is now only valid, if i enter one of the bad words … this return !/nice site|good work|xxx|aciphex|url=http|nude/.test(value); works fine. On 22 Sep., 14:32, Jörn Zaefferer [EMAIL PROTECTED] wrote: Sure. You can create a regexes on the fly with new RegExp(bla) and use that instead of the inline regex /bla|blu/. Jörn On Mon, Sep 22, 2008 at 1:37 PM, tobaco [EMAIL PROTECTED] wrote: uh, that was fast! thx, i will give it a try. aehm, is it possible to put the bad word in an array and test this. On 22 Sep., 13:31, Jörn Zaefferer [EMAIL PROTECTED] wrote: return !/bad|word|must|not|match/.test(value); Jörn On Mon, Sep 22, 2008 at 1:25 PM, tobaco [EMAIL PROTECTED] wrote: hi, i'm using the excellent validate-plugin and it works like a charm. now i want to test the text in a textarea against a list of bad words. how must be the syntax of the custom validation rule? i'm very bad in regex … thanks in advance, tobaco