Angular2 email validation
Try Something like that
<div class="alert-email">
<label>Email</label>
<input
id="contactemail"
type="text"
#contactemail="ngModel"
[(ngModel)]="model.contactemail"
required
pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$">
<div class="md-errors-spacer" [hidden]="contactemail.valid || contactemail.untouched">
<div *ngIf="contactemail.errors && contactemail.errors.required">
Email is required
</div>
<div *ngIf="contactemail.errors && contactemail.errors.pattern">
Email is invalid
</div>
</div>
</div>
Angular 4 has a built-in "email" validation tag that can be added within the input. E.g.:
<input type="email" id="contactemail" email>
This will be valid for a series of numbers and letters then an @ then another series of letters. It will not account for the dot after the @ -- for that you can use the "pattern" tag within the input and your standard regex.