Email validation


#1

I’ve been searching around for a while now and couldn’t find a simple standard email validator to validate an email entry into an input field. Surely there much be a standard solution for this??? Can anyone please advice? Many thanks!


Forms validation email - just can find a working example
#2
  email: ['', Validators.compose([Validators.maxLength(70), Validators.pattern('^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$'), Validators.required])]

#3

Thanks for your help @dimitri320


#4

where to paste this code for email validation?


#5

so first you need to import this stuff:

import { FormBuilder, FormGroup, Validators } from '@angular/forms';

Then you wanna use a form to validate your form inputs:

    this.stripeForm = formBuilder.group({
      email: ['', Validators.compose([Validators.maxLength(70), Validators.pattern('^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$'), Validators.required])]
    });

And then your input:

<ion-input formControlName="email" type="email" [(ngModel)]="email"></ion-input>