Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i get ngx-mask masked value?

I'm trying to create simple field for phone number with help of ngx-mask module like this:

<mat-form-field>
              <input matInput formControlName="PhoneNumber" placeholder="Phone number" mask="(000) 0000-00" prefix="+1" [showMaskTyped]="true">
</mat-form-field>

It works, but value in control PhoneNumber is 999999999. How can i save in control value with mask, ie special symbols and prefix? Basically i need to save value which user sees: +1(999) 9999-99

like image 281
Kngh2 Avatar asked Mar 13 '20 08:03

Kngh2


1 Answers

Use [dropSpecialCharacters]="false"

<mat-form-field>
   <input matInput formControlName="PhoneNumber" placeholder="Phone number" mask="(000) 0000-00" prefix="+1" [showMaskTyped]="true" [dropSpecialCharacters]="false">
</mat-form-field>
like image 193
gfinotti Avatar answered Oct 04 '22 21:10

gfinotti