Home > other >  How to cancel validation in onValueChanged function in angular?
How to cancel validation in onValueChanged function in angular?

Time:07-05

How to cancel validation in onValueChanged function in angular?

Here is demo

When I finish the form, I change the device value. You can see that a validation will be trigger in the apple phone. However, I set the validation in the field touched. I don't want to show this message while I click the device (onValueChanged function). It trigger the "touched" validation. Any one can help?

CodePudding user response:

Why not change the form control to pristine and untouched. Then form validations will not show.

  deviceListOnChange(e) {
    this.updateForm.controls.apple.setValue(null);
    this.updateForm.controls.apple.markAsPristine();
    this.updateForm.controls.apple.markAsUntouched();
  }

stackblitz

  • Related