I have an input using the ngx-mask
<input type="text" [mask]="maskPhoneFormat" formControlName="contactPhone" />
In the ts file I use:
this.contactPopupForm.get('contactPhone')?.updateValueAndValidity();
because I change the Validator for that Input, after that the ngx-mask ("requiredMask") stop working on that input, any ideas?
I create a stackblitz with example
https://stackblitz.com/edit/angular-ivy-lf8e1s?file=src/app/app.component.html
The first time you introduce the phone number works good, after introducing a name and editing the phone number again, the ngx-mask doesn't works properly
You can just replace setValidators
by addValidators
.
The difference is: add
will append
new validators. set
will replace
the current with new validators
Same goes with removeValidators
and clearValidators