I have a form in which based on a condition i need to disable the required validator from the form control. My current code looks like this.
address: new FormControl('', Validators.required)
this.dealForm.get('address').clearValidators();
this.dealForm.get('address').setValidators();
this.dealForm.get('address').updateValueAndValidity();
From this piece of code this form control still has the required validator. Does anybody have any suggestion regarding my issue ? Followed suggestions from another topic, the required validator still present and form is invalid
Thank for your help guys, your answers were working. I had a problem with the way I was accessing the form data.
setValidators()expects at least one argument... :). Your code will not run. Though you only needclearValidators()to remove the validators, no need to useupdateValueAndValidity()after.this.dealForm.get('address').setValidators(null);if this does not work pls provide a stackblitz