Home > Web Front-end > JS Tutorial > Regular verification in JQ cannot contain Chinese methods

Regular verification in JQ cannot contain Chinese methods

php中世界最好的语言
Release: 2018-03-29 17:59:11
Original
4122 people have browsed it

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

Java verification string does not contain Chinese

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

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!

Related labels:
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