I have a form with validation in the fields. I want to remove the validation on a specific condition.
I already tried clearValidators(), setErrors(null), setValidators(null), and updateValueAndValidity(), but none of these worked.
I have a form with validation in the fields. I want to remove the validation on a specific condition.
I already tried clearValidators(), setErrors(null), setValidators(null), and updateValueAndValidity(), but none of these worked.
setValidators(null), must be work. It's posible you need call to updateValueAndValidity() in a setTimeout to remove the errors. If I supouse your formGroup is called form
and has a formControl called myControl
this.form.get("myControl").setValidators(null)
setTimeout(()=>{
this.form.get("myControl").updateValueAndValidity()
})
NOTE: If you disabled the control, the form don't take account the validators
this.form.get("myControl").disable()