Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an event to know when a form is valid?

I am using FormGroup, custom validators, etc. I need to capture in an event handler when the form becomes valid/invalid, not a property, but an actual event in TypeScript code.

I took a look to the documentation, but I wasn't able to find something like: (validityChange)="myEventHandler($event)"

where validityChange is just a placeholder for the name of the actual event I am looking for.

like image 995
Will de la Vega Avatar asked Sep 14 '16 22:09

Will de la Vega


1 Answers

Subscribe to statusChanges

this.myForm.statusChanges
.filter(s => s == 'VALID')
.subscribe(val => onValid())
like image 196
Günter Zöchbauer Avatar answered Sep 28 '22 05:09

Günter Zöchbauer