1 year ago
#349182
Bala
How to Check the Angular Reactive Form Validation When a Button is pressed
I want to check the form validation when a button is pressed or to say it in another word I want web page to look like this exactly on button press.
Reactive form code I have written is given below.
schemeForm = this.fb.group({
bankDetails: this.fb.group({
Name: [null, Validators.required],
Branch: [null, Validators.required],
acHolder: [null, Validators.required],
acNumber: [null, Validators.required],
IFSCCode: [null, Validators.required],
passBook: [null, Validators.required]
}),
});
get getbankDetails() {
return this.schemeForm.get('bankDetails');
}
bankFormValid() {
if (this.getbankDetails?.invalid) {
this.getbankDetails?.markAsTouched({onlySelf: true})
this.getbankDetails?.dirty
console.log('invalid')
//here this code work properly But the colour doesn't change automatically to red.
}
}
Template Code: https://gist.github.com/srbalakkl/d921c4c653704855e3540ed9fb8bbe4f
html
angular
angular-reactive-forms
formgroups
0 Answers
Your Answer