📜  打字稿代码示例中的电子邮件验证

📅  最后修改于: 2022-03-11 14:48:20.503000             🧑  作者: Mango

代码示例1
validateEmail(email) {
    if(email!=''){
      const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
      console.log(re.test(String(email).toLowerCase()))
      this.emailTest = re.test(String(email).toLowerCase())
      if (this.emailTest != true) {
        this.toastr.warning("please enter valid email")
        return;
      }

    }
    }