Validate field for all language characters through REGEX

后端 未结 3 717
离开以前
离开以前 2021-02-10 01:05

i need to validate a field for empty. But it should allow English and the Foreign languages characters(UTF-8) but not the special characters. I\'m not good at R

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-10 01:31

    It would have been nice if I could say "Just do /^\w+$/.test(word)", but...

    See this answer for the current state of unicode support (or rather lack of) in JavaScript regular expressions.

    You can either use the library he suggests, which might be slow or enlist the help of the server for this (which might be slower).

提交回复
热议问题