Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 修复手机号码匹配,运营商新增号段如166、191 等开头号码无法通过验证问题 #112

Merged
merged 1 commit into from
Apr 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/utils/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function validEmail(email) {
}

export function isvalidPhone(phone) {
const reg = /^1[3|4|5|7|8][0-9]\d{8}$/
const reg = /^1([38][0-9]|4[014-9]|[59][0-35-9]|6[2567]|7[0-8])\d{8}$/
return reg.test(phone)
}

Expand Down Expand Up @@ -112,7 +112,7 @@ export function validateIP(rule, value, callback) {

/* 是否手机号码或者固话*/
export function validatePhoneTwo(rule, value, callback) {
const reg = /^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/
const reg = /^((0\d{2,3}-\d{7,8})|(1([38][0-9]|4[014-9]|[59][0-35-9]|6[2567]|7[0-8])\d{8}))$/
if (value === '' || value === undefined || value == null) {
callback()
} else {
Expand Down Expand Up @@ -140,7 +140,7 @@ export function validateTelephone(rule, value, callback) {

/* 是否手机号码*/
export function validatePhone(rule, value, callback) {
const reg = /^[1][3,4,5,7,8][0-9]{9}$/
const reg = /^1([38][0-9]|4[014-9]|[59][0-35-9]|6[2567]|7[0-8])\d{8}$/
if (value === '' || value === undefined || value == null) {
callback()
} else {
Expand All @@ -165,4 +165,3 @@ export function validateIdNo(rule, value, callback) {
}
}
}