Basically what i am trying to do is validate a form. In one of the fields i want to allow spaces:
I've been using:
$.validator.addMethod(
"legalname",
function(value, element) {
return this.optional(element) || /^[a-zA-Z0-9()._-\s]+$/.test(value);
},
"Illegal character. Only points, spaces, underscores or dashes are allowed."
);
$("#editform").validate({
rules: {
name: {
required: true,
legalname: true
},
});
This works in Safari, but not in Firefox where it gives me a "invalid range in character class". Any ideas how i can get this working?
}on thevalidate(), and older versions of IE can flip out over trailing commas like the one belowname:.