Please refer the project in a stackblitz here.
As can be seen, I have reactive form with controls as firstNumber, secondNumber and thirdNumber. I need to have validation for form control thirdNumber such that its value should not be greater than the value of the form control which is having minimum value among firstNumber and secondNumber.
The custom validator validateThirdNumber which is there in the component works fine whenever form control thirdNumber changes, but I need
fire its validation on changes of form controls firstNumber and secondNumber too as the validation logic can change on changes of form controls
firstNumber and secondNumber.
For that purpose, I have added an event on change of form controls firstNumber and secondNumber where I am marking the form control thirdNumber as touched but its validation did not seem to be triggered.
So, how to fire the validation for form control thirdNumber on changes of form controls firstNumber and secondNumber?
Also, why is this.myFormGroup is undefined some times in custom validator (refer logs in app.componen.ts at line:22) even after binding this to its form control declaration and this.myFormGroup is defined in the constructor?
updateValueAndValidity()function .check this out stackoverflow.com/questions/44759005/….