Hi I am working on Angular8 with Template Driven forms, wherein i want to validate multiple email id, i have 2 email fields one is To
and the other is CC
. If the email id is present and if it is valid then i am enabling Send Email Button, but when i tried to use multiple email id, the validation fails and i get an eror as Invalid email id. Here if there is one email id also it must validate, if it is multiple email id also it must validate.
HTML:
<div class="row mb-3">
<div class="col-2">To:</div>
<div class="col"><input type="email" class="form-control" autocomplete="off" [(ngModel)]="userMail" pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" #userContactemail="ngModel" placeholder="Email" >
<div class="md-errors-spacer email-error"
[hidden]="userContactemail.valid || userContactemail.untouched">
<div *ngIf="userContactemail.errors && userContactemail.errors.pattern" class="error">
Invalid Email
</div>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-2">Cc:</div>
<div class="col"><input type="email" class="form-control" [(ngModel)]="userCC" pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" #userContactCC="ngModel" placeholder="Email" >
<div class="md-errors-spacer email-error"
[hidden]="userContactCC.valid || userContactCC.untouched">
<div *ngIf="userContactCC.errors && userContactCC.errors.pattern" class="error">
Invalid Email
</div>
</div>
</div>
</div>