You can safely remove the first modification, thats not necessary. Its used for required only to move the method to the front (which is actually a bad workaround). Anyway:
I've commented on regex-methods here: http://docs.jquery.com/Plugins/Validation/Validator/addMethod#namemethodmessage Please note: While the temptation is great to add a regex method that checks it's parameter against the value, it is much cleaner to encapsulate those regular expressions inside their own method. If you need lots of slightly different expressions, try to extract a common parameter. A library of regular expressions: http://regexlib.com/DisplayPatterns.aspx Jörn On Fri, Dec 5, 2008 at 8:01 PM, skidmarek <[EMAIL PROTECTED]> wrote: > > I've created a useful addition to your class that you may want to > include in a future version. > > Set the value of the regex attribute to a regular expression. If any > characters in the input don't match the regex, it returns false. Very > handy. > > Here's the source: > > ------------------------------------------- In rules: > > if (data.regex) { > var param = data.regex; > delete data.regex; > data = $.extend({regex: param}, data); > } > > ------------------------------------------- Then in methods: > > regex: function(value,element,param) { > if (param) { > var expression = new RegExp(param, "g"); > return (value.replace(expression,"").length==0); > } else { > return true; > } > }, > > ------------------------------------------- Usage: > > regex: "\\b[a-zA-Z0-9()[EMAIL PROTECTED]"'?&* ]+\\b" > > If the input contains any characters that aren't in that list, it > validates as false. >