Home >Java >javaTutorial >Regular verification cannot contain Chinese implementation methods [jQuery and java implementation]
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 hope this article will be helpful for everyone to learn regular expressions.
For more implementation methods that cannot contain Chinese for regular verification [jQuery and java implementation], please pay attention to the PHP Chinese website for related articles!