Home  >  Article  >  Web Front-end  >  How to write the login and registration front-end verification input format

How to write the login and registration front-end verification input format

一个新手
一个新手Original
2017-09-22 10:10:362017browse

When logging in and registering, sometimes the front-end needs to verify the legality of the content input format. Here are some simple and commonly used verifications

1. Verify mobile phone number

var reg= /^1[3-578]\d{9}$/

2. Verify name

 var reg=/^[\u4e00-\u9fa5a-zA-Z0-9]{2,10}$/

3. Verify password

var reg = /^(?!\D+$)(?![^a-zA-Z]+$)\S{8,}$/;//密码必须是数字 字母 特殊字符 不支持空格  最少8位

4. Verify verification code

var reg = /^[a-zA-Z0-9]{4}$///只能是4位的字母和数字

These four should be the most commonly used verifications

reg.test(验证的内容);

The above is the detailed content of How to write the login and registration front-end verification input format. For more information, please follow other related articles on the PHP Chinese website!

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