Last active
September 1, 2017 11:24
-
-
Save javebratt/2fdd968e3f3c92886a34d1159bd4c09e to your computer and use it in GitHub Desktop.
Email Validator what works for NG2 and Ionic 2 apps.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {FormControl} from '@angular/forms'; | |
export class EmailValidator { | |
static isValid(control: FormControl){ | |
var 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,}))$/.test(control.value); | |
if (re){ | |
return null; | |
} | |
return {"invalidEmail": true}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to check with ngIf in html file?
and i'm using ionic2..