email validation in typescript

Solutions on MaxInterview for email validation in typescript by the best coders in the world

showing results for - "email validation in typescript"
Odalis
21 Jul 2020
1  validateEmail(email) {
2    if(email!=''){
3      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,}))$/;
4      console.log(re.test(String(email).toLowerCase()))
5      this.emailTest = re.test(String(email).toLowerCase())
6      if (this.emailTest != true) {
7        this.toastr.warning("please enter valid email")
8        return;
9      }
10
11    }
12    }