Reputation: 1262
Scenario: User want to retrieve email or reset password. Person will select respective option as per requirement. Submit button will get enable only when form is valid.
Problem: I want to dynamically update validation according to selected option. But it is not working. Definitely I'm missing something. I used clearValidators, but it is also not working. Here is the working code.
For testing use: email : [email protected] password: Test@1234
Upvotes: 2
Views: 1312
Reputation: 3727
Try updating the individual controls value and validity. For example
this.loginTroubleForm.get('email').updateValueAndValidity();
Do this for each control for which you are setting the validator to null.
Upvotes: 6