Skip to content

Instantly share code, notes, and snippets.

@javebratt
Last active September 1, 2017 11:24
Show Gist options
  • Save javebratt/2fdd968e3f3c92886a34d1159bd4c09e to your computer and use it in GitHub Desktop.
Save javebratt/2fdd968e3f3c92886a34d1159bd4c09e to your computer and use it in GitHub Desktop.
Email Validator what works for NG2 and Ionic 2 apps.
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};
}
}
@pooja2695
Copy link

pooja2695 commented Sep 1, 2017

how to check with ngIf in html file?
and i'm using ionic2..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment