You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.7 KiB
69 lines
1.7 KiB
|
|
function verificationPhone(countryCode,phoneNumber) {
|
|
switch (countryCode) {
|
|
case '+86':
|
|
return verificationChina(phoneNumber);
|
|
case '+1':
|
|
return verificationAmerica(phoneNumber);
|
|
case '+65':
|
|
return verificationSingapore(phoneNumber);
|
|
case '+60':
|
|
return verificationMalaysia(phoneNumber);
|
|
case '+66':
|
|
return verificationThailand(phoneNumber);
|
|
case '+852':
|
|
return verificationHongKong(phoneNumber);
|
|
case '+84':
|
|
return verificationVietnam(phoneNumber);
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
function verificationChina(phoneNumber){
|
|
const phoneRegex = /^1[3-9]\d{9}$/;
|
|
return phoneRegex.test(phoneNumber);
|
|
}
|
|
|
|
|
|
function verificationAmerica(phoneNumber){
|
|
const phoneRegex = /^[2-9]\d{2}[- ]?\d{4}$/;
|
|
return phoneRegex.test(phoneNumber);
|
|
}
|
|
function verificationSingapore(phoneNumber){
|
|
const phoneRegex = /^[89]\d{7}$/;
|
|
return phoneRegex.test(phoneNumber);
|
|
}
|
|
function verificationMalaysia(phoneNumber){
|
|
const phoneRegex = /^01\d{8}$/;
|
|
return phoneRegex.test(phoneNumber);
|
|
}
|
|
|
|
function verificationHongKong(phoneNumber){
|
|
const phoneRegex = /^0[896]\d{8}$/;
|
|
return phoneRegex.test(phoneNumber);
|
|
}
|
|
|
|
|
|
function verificationThailand(phoneNumber){
|
|
const phoneRegex = /^[5-9]\d{7}$/;
|
|
return phoneRegex.test(phoneNumber);
|
|
}
|
|
|
|
|
|
|
|
function verificationVietnam(phoneNumber){
|
|
const phoneRegex = /^(0)?[3-9]\d{8}$/;
|
|
return phoneRegex.test(phoneNumber);
|
|
}
|
|
|
|
|
|
|
|
|
|
function verificationEmail(email) {
|
|
const emailRegex = /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/;
|
|
return emailRegex.test(email);
|
|
}
|
|
|
|
export {verificationPhone,verificationEmail}
|