I am using reactive form validation here. I have 3 fields Email, Full Name & Password (All are mandatory). When I just click on any one of the fields and just click off the fields. By default, Angular shows red color border over the fields
I would like to show the red color border when I type in the fields and remove all the text and click outside.
I don't want to show red color border when I just click into the fields and click off the fields.
How to override this default behavior?
Template
<form name="form" (ngSubmit)="onSubmit(signUpForm)" #f="ngForm"
#signUpForm="ngForm" [formGroup] = "signup"
fxShow="true" fxFlex fxLayout="column" fxLayoutAlign="center stretch" fxLayoutGap="4px">
<div>
<mat-form-field appearance="outline">
<mat-label>Email</mat-label>
<input matInput placeholder="Enter the email" name="email" formControlName="email">
</mat-form-field>
</div>
<div>
<mat-form-field appearance="outline">
<mat-label>Full Name</mat-label>
<input matInput placeholder="Enter your fullname" name="fullname" formControlName="fullname">
</mat-form-field>
</div>
<div>
<mat-form-field appearance="outline">
<mat-label>Password</mat-label>
<input matInput placeholder="Enter the password" name="password" formControlName="password">
</mat-form-field>
</div>
<div>
<button class="btn btn-info height_40" type="submit" [disabled]="signup.invalid" fxFlex="98">
Sign Up
</button>
</div>
</form>
Typescript file
export class SignupComponent implements OnInit {
signup: FormGroup;
constructor(private formBuilder: FormBuilder) {
this.signup = formBuilder.group({
email: ['', Validators.required],
fullname: ['', Validators.required],
password: ['', Validators.required]
})
}
}