【问题标题】:regular expression for Indian mobile numbers, Email Id and Password : React Js || Next Js印度手机号码、电子邮件 ID 和密码的正则表达式:React Js ||下一个 Js
【发布时间】: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


    【解决方案1】:
        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;
        }
      };```
    

    【讨论】:

      猜你喜欢
      • 2013-08-23
      • 1970-01-01
      • 2018-12-29
      • 2012-03-24
      • 2012-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多