123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- //验证密码的正则 产品定的规则是:8位及以上,包含数字、大写字母、小写字母、特殊字符中的三个类型
- export const patternPassWord = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/
- export function checkPassWord(pwd){
- let num = 0
- const patternArr = [
- /^(?=.*[0-9])/,
- /^(?=.*[a-z])/,
- /^(?=.*[A-Z])/,
- /^(?=.*[@#$%^&+=.])/,
- ]
- patternArr.forEach(pattern=>{
- if(pattern.test(pwd)){
- num++
- }
- })
- if(pwd.length<8){
- num = 0
- }
- return num>=3
- }
- //验证手机号的正则 仅支持国内大陆的
- export const patternPhone = /0?(13|14|15|18|17)[0-9]{9}/
- export function isMobileNo(account) {
- /* // 手机号正则
- var isChinaMobile = new RegExp(
- "(^1(3[4-9]|4[78]|5[0-27-9]|7[28]|8[2-478]|98)\\d{8}$)"
- ); // 中国移动
- // 手机段:134,135,136,137,138,139,147,148[卫星通信],150,151,152,157,158,159,172,178,182,183,184,187,188,198
- var isChinaUnicom = new RegExp(
- "(^1(3[0-2]|4[56]|5[56]|66|7[156]|8[56])\\d{8}$)"
- ); // 中国联通
- // 手机段:130,131,132,145,146[卫星通信],155,156,166,171,175,176,185,186
- var isChinaTelcom = new RegExp("(^1(33|49|53|7[347]|8[019]|99)\\d{8}$)"); // 中国电信
- // 手机段:133,149,153,173,174,177,180,181,189,199
- var isOtherTelphone = new RegExp("(^170\\d{8}$)");
- // 虚拟运营商170号段
- if (isChinaMobile.test(account)) {
- return true;
- } else if (isChinaUnicom.test(account)) {
- return true;
- } else if (isChinaTelcom.test(account)) {
- return true;
- } else return isOtherTelphone.test(account); */
-
- //改成和后端一样的正则
- const phonePatter = new RegExp("(^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-9])|(17[0-9])|(16[0-9])|(19[0-9]))\\d{8}$)")
- return phonePatter.test(account)
- }
- //验证邮箱的正则
- export const patternEmail = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/
|