【发布时间】:2021-09-08 02:24:20
【问题描述】:
这是印度本地手机号码验证和印度国际的正则表达式。
从 9、8、7 开始,您还可以添加更多。
电子邮件和密码
听到的是密码
请尽快订阅制作视频 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;
}
};```
【问题讨论】:
标签: reactjs validation authentication email-validation