I want to create a jQuery validation method to validate according to the following rules:
- English letters .
A-Z , a-z. - Non English letters
\u0080-\u024F. - and for these characters – / ) ( ` . ” ‘
- and space character
Currently I am using:
jQuery.validator.addMethod("custommethod", function(value, element) {
return this.optional(element) || /^[a-zA-Z\u0080-\u024F ]+$/i.test(jQuery.trim(value));
}, "You Have Typed Invalid Characters");
Currently I have done the validation for step 1,2,4. But when I try to add step 3 it fails.
How do I add step 3 to the validation?
Just add characters that may be part of a RegExp in escaped form:
See also, especially Table 4.1 Special characters in regular expressions.