I would like to use JQuery Validation to validate a text input field for text input. But with spaces and the german special characters (äöüß).
For this I have created an additional method "letterspecial":
jQuery.validator.addMethod("letterspecial", function(value, element) {
return this.optional(element) || /^[a-zA-Z\u0196\u0228\u0214\u0246\u0220\u0252\u0223]+$/.test(value);
}, "Letters only please with Special Charts and Spaces allow");
I'm pretty sure it's the RegEx, however I don't know how to set it correctly.
But maybe there is another solution?
Thanks a lot
You can simply use äöüß in your regex, no need for escaped unicode characters, as far as I can tell :
const regex = /^[a-zA-Zäöüß]+$/;
console.log(regex.test("üßeörgä"))
console.log(regex.test("héhé this is invalid hôhô"))