Instead of your name is required I want that animated pulse classes should be added to the input field. Both these classes are from animate.css library which displays pulse effect and the class should also be removed once the user enters a valid text to reset the animation so that the animation shows again if the user does something wrong on that input field agin.
<form method="post" [formGroup]="registerForm" (ngSubmit)="onSubmit()">
<input type="text" formControlName="first_name" name="first_name" placeholder="First Name *"/>
<div *ngIf="registerForm.controls.first_name.errors && registerForm.controls.first_name.touched" class="error">
<div *ngIf="registerForm.controls.first_name.errors.required">Your name is required</div>
</div>
<div *ngIf="submitted && registerForm.controls.first_name.errors && registerForm.controls.first_name.pristine" class="error">
<div *ngIf="registerForm.controls.first_name.errors.required">Your name is required</div>
</div>
.ts
this.registerForm = this.formBuilder.group({
first_name: ['', Validators.required],
onSubmit() {
this.submitted = true;
if (this.registerForm.invalid) {
return;
}
}