This time I will bring you the method of not containing Chinese characters in the regular verification in JQ, and the precautions of the regular verification in JQ that cannot contain Chinese characters. The following is a practical case, let’s take a look.
The example in this article describes the implementation method of regular verification that cannot contain Chinese. Share it with everyone for your reference, the details are as follows:
jQuery uses regular verification to not contain Chinese
var myReg = /^[a-zA-Z0-9_]{0,}$/; if (!myReg.test(input.val())) { $.validation.tip(false, input, "用户名不能含有中文或特殊字符"); return; }
Java verification string does not contain Chinese
if (nickname.getBytes().length != nickname.length()) { errors.add("用户名不能含有中文"); }
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
How to match consecutive numbers with regular expressions
Development experience of implementing minimum matching with regular expressions
The above is the detailed content of Regular verification in JQ cannot contain Chinese methods. For more information, please follow other related articles on the PHP Chinese website!