简体   繁体   中英

validate firstname and lastname

First my English is not so good, so please understand what I am trying to say.

I previously asked this question , but I did not get an answer that I wanted. That's why I write this question.


I want users to be able to set their name in any language. But there are some rules:

Names can't include:

  • Symbols, numbers, unusual capitalization
  • Characters or punctuation or icon that is not in any language, like this(⧇ ⧈ ⧉ ⧊ ⧋ ⧌⛋ ⛌ ⛍ ⛎ ⛏ ⛐ ⛑ ⛒ ⛓ ⛔)
  • Characters from multiple languages

How can I validate names with these kind of rules?

It is a suggestion, you can give a try to Regual Expressions, named also Regex.

Check this out: 8 Regular Expressions You Should Know

Hope it gives you a hint.

Sounds like you need some pretty specific preg_match rules. If you take some of the advice from the previous question you asked and mash that up with that language detection service you found, you should be able to detect the language, then compare the first and last name against a pre-defined list of unacceptable characters and, if you find them, reject the name. After that check, you should be able to check the first name language, the last name language, then compare those results and figure out if they are in the same language and, if not, reject.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM