Home > Java > javaTutorial > body text

Regular verification cannot contain Chinese implementation methods [jQuery and java implementation]

高洛峰
Release: 2017-01-22 14:35:26
Original
1510 people have browsed it

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;
}
Copy after login

Java verification string does not contain Chinese

if (nickname.getBytes().length != nickname.length()) {
  errors.add("用户名不能含有中文");
}
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template