Trying to debug an issue with my reactive forms - the repeatPassword field doesn't update as expected. When entering information in the "password" field, then the "repeatPassword" field, and back to "password", the second entry is not flagged as invalid.
To address this issue, I attempted the following solution:
if (this.form.get('password').value !== this.form.get('passwordRepeat').value) {
this.form.get('passwordRepeat').setErrors({'invalid': true});
}
if (this.form.get('password').value === this.form.get('passwordRepeat').value && !this.form.get('passwordRepeat').hasError) {
this.form.get('passwordRepeat').setErrors({'invalid': null});
}
While the code appears to be correct, when trying to reset the invalid status to null, the reactive forms interpret it as an error, preventing submission and displaying an error message from ngIf.
A similar issue arises when attempting to validate rules - deselecting a checkbox does not mark it as invalid.
Is there a way to force validators to re-run for these scenarios?