这是印度本地手机号码验证和印度国际手机号码验证的正则表达式。
从9,8,7开始,你还可以添加更多。
电子邮件和密码
Hear是代码
请立即订阅制作视频My Youtube Channel
const status = validate();
if (status === true) {
alert('Login');
}
};
const doSignUp = () => {
const status = validate();
if (status === true) {
alert('Sign Up');
}
};
const validate = () => {
if (
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(
email
) &&
email.includes('.')
) {
if (
/^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]{6,99}$/.test(password)
) {
if (
/^(?:(?:\+|0{0,2})91(\s*[\-]\s*)?|[0]?)?[6789]\d{9}$/.test(
phoneNumber
)
) {
return true;
} else {
alert('Invalid Phone Number');
return false;
}
} else {
alert(
'Invalid, Password should contane Capital Letter, Small Letter , Number and Symbol'
);
return false;
}
} else {
alert('You have entered an invalid email address!');
return false;
}
};```发布于 2021-06-24 23:07:32
const status = validate();
if (status === true) {
alert('Login');
}
};
const doSignUp = () => {
const status = validate();
if (status === true) {
alert('Sign Up');
}
};
const validate = () => {
if (
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(
email
) &&
email.includes('.')
) {
if (
/^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]{6,99}$/.test(password)
) {
if (
/^(?:(?:\+|0{0,2})91(\s*[\-]\s*)?|[0]?)?[6789]\d{9}$/.test(
phoneNumber
)
) {
return true;
} else {
alert('Invalid Phone Number');
return false;
}
} else {
alert(
'Invalid, Password should contane Capital Letter, Small Letter , Number and Symbol'
);
return false;
}
} else {
alert('You have entered an invalid email address!');
return false;
}
};```https://stackoverflow.com/questions/68118324
复制相似问题