Categories
Angular

Angular Reactive form Validations

Validating input in reactive forms

Validator functions
Validator functions can be either synchronous or asynchronous.

Sync validators: Synchronous functions that take a control instance and immediately return either a set of validation errors or null. You can pass these in as the second argument when you instantiate a FormControl.

Async validators: Asynchronous functions that take a control instance and return a Promise or Observable that later emits a set of validation errors or null. You can pass these in as the third argument when you instantiate a FormControl.

Categories
Angular

Angular 7 -Reactive Forms Validation

<label class="label-control">Username*</label>
<input type="text" autocomplete="new-password" formControlName="username" class="form-control" (blur)="verifyUsername($event.target.value)" minlength="1" maxlength="20">
<div *ngIf="editAuthenticationform.controls['username'].invalid && (editAuthenticationform.controls['username'].dirty || editAuthenticationform.controls['username'].touched)" class="error formError">
<div *ngIf="editAuthenticationform.controls['username'].errors.required">Username is required.</div></div>