Reputation: 1607
I am quite confused on the issue of validating the fields (eg. business name, company name, address, etc.), because the site has localization feature. Currently, I am validating the fields using jQuery via regular expression, a snip of one of my regex:
var regex = /^[a-zA-Z0-9-,.\säöüÄÖÜ]{2,}$/;
This works fine when the site is in English language. However, I am not confident if this does work in German environment.
What I do to test my validation is by using Character Map on Windows. Say for example, I get ü from Character Map, paste it on the field. But the script says it is an invalid character. Whereas, if you look on the regex, I am considering such character as valid.
Upvotes: 0
Views: 580
Reputation: 201518
Most probably the technical problem is in the document’s character encoding. Make sure that your document is UTF-8 encoded and declared as such in HTTP headers or at least in a meta
tag.
There are more difficult important problems though. Your regexp will reject the English name Brontë and the German name Strauß for example. And it will accept 42, which is hardly anyone’s first or last name.
What is the purpose of this checking? Can you expect that all the names will be English or German? According to European conventions, a person has the right to have his name spelled correctly in European countries, even if it happens to be in a language other than the majority language.
There’s not much checking of personal names that you can do without risk of rejecting someone’s real name in some accepted spelling. If you need to force names to some limited character repertoire or syntax, this needs to be made clear to users and performed server-side and, preferably, additionally as client-side pre-checking.
Upvotes: 1