How to validate both Chinese (unicode) and English name?

前端 未结 5 1320
说谎
说谎 2021-02-01 10:14

I have a multilingual website (Chinese and English).

I like to validate a text field (name field) in javascript. I have the following code so far.

var c         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-01 10:30

    I have done some work on validating Chinese names using XRegExp. The core code is XRegExp("^((?![\\p{InKangxi_Radicals}\\p{InCJK_Radicals_Supplement}\\p{InCJK_Symbols_and_Punctuation}])\\p{Han}){2,4}$","u")

    See jsfiddle.net/coas/4djhso1y

提交回复
热议问题