Home >Web Front-end >JS Tutorial >An example of using regular expressions to verify input content in a js input box

An example of using regular expressions to verify input content in a js input box

高洛峰
高洛峰Original
2017-02-15 17:09:521462browse

js input box input verification

/*用户名称格式判断——用户名只能为下划线、数字、字母或中文长度不超过10个字符*/

function checkUserName(str) {
var reg = /^[_0-9a-zA-Z\u4e00-\u9fa5]{1,10}$/;
return reg.test(str);
}

The above example of the js input box using regular expressions to verify input content This is all the content that the editor has shared with you. I hope it can give you a reference and I hope you will support the PHP Chinese website.

For more examples of js input boxes using regular expressions to verify input content, please pay attention to the PHP Chinese website for related articles!

Statement:
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