Hello there, I'm new to Angular and looking for some assistance. Specifically, I am currently working on validating an email input using a reactive form with the keyup event.
registerform:any;
ngOnInit(): void {
this.registerform = new FormGroup({
"emailId": new FormControl(null,[Validators.required,Validators.email])
});
}
get emailid() { return this.registerform.get('emailId');}
<form [formGroup]="registerform" (ngSubmit) = "submitData()">
<input type="text" formControlName="emailId" placeholder="email">
<div *ngIf="emailid.invalid && (emailid.touched || emailid.dirty)">
<span class="myerror" name="err" *ngIf="emailid.errors?.required">*Email is required.</span>
<span class="myerror" name="err" *ngIf="emailid.errors?.email">*Email is not valid.</span>
</div>
</form>