前端相关的正则校验
1.常规手机号校验
const reg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
或
const reg = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/
2.座机号码校验
const reg = /^(0\d{2,3})-?(\d{7,8})$/
3.邮箱校验
const reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
4.身份证号校验
//普通校验
const reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
//18位严格校验
const reg = /^[1-9]\d{5}(19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
//后六位校验
const reg = /^(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
//15位校验
const reg = /^[1-9]\d{5}\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]$/
5.邮政编码校验
const reg = /^[1-9]\d{5}$/
6.QQ号校验
const reg = /^[1-9][0-9]\d{4,9}$/
7.注册账号校验
const reg = /^[a-zA-Z][a-zA-Z0-9_]{4,15}$/
8.名称/名字校验(字符校验)
//字符长度2-20
const reg = /^([\u4e00-\u9fa5]{2,20}|[a-zA-Z.\s]{2,20})$/
9.纳税人识别号校验
const reg = /^[A-Z0-9]{15}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/;
if (value) {
if (!reg.test(value)) return false;
return true;
} else {
return false;
}
标签:20,校验,15,正则,相关,Z0,reg,const From: https://www.cnblogs.com/qiushuiyu-108/p/17219142.html