手机号正则校验

This commit is contained in:
yy 2024-06-03 14:24:41 +08:00
parent a44ae3433d
commit f7b3ec3756
4 changed files with 4 additions and 5 deletions

View File

@ -107,7 +107,7 @@ const validatorPhone = (rule: any, value: any, callback: any) => {
return callback().trim();
}
if (!new RegExp(REGEXP.PHONE).test(value)) {
if (!new RegExp(REGEXP.MOBILE).test(value)) {
callback(new Error('请输入合法手机号'));
} else {
callback();

View File

@ -9,5 +9,5 @@ export enum LogTypeEnum {
export enum REGEXP {
PASSWORD = '^[a-zA-Z0-9]{8,16}$',
ACCOUNT = '^[a-zA-Z0-9]{2,16}$',
PHONE = '^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$'
MOBILE = '^[1][3,4,5,6.7,8,9][0-9]{9}$'
}

View File

@ -158,11 +158,10 @@ const phoneAreas: any = getPhoneAreasData()
let loading = ref(false);
//
const validatorPhone = (rule: any, value: any, callback: any) => {
var isPhone = /^1[34578]\d{9}$/;
if (value.indexOf('****') >= 0) {
return callback().trim();
}
if (!isPhone.test(value)) {
if (!new RegExp(REGEXP.MOBILE).test(value)) {
callback(new Error('请输入合法手机号'));
} else {
callback();

View File

@ -84,7 +84,7 @@ const validatorPhone = (rule: any, value: any, callback: any) => {
if (value.indexOf('****') >= 0) {
return callback().trim();
}
if (!new RegExp(REGEXP.PHONE).test(value)) {
if (!new RegExp(REGEXP.MOBILE).test(value)) {
callback(new Error('请输入合法手机号'));
} else {
callback();