12

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

Kngh2
  • 387
  • 2
  • 4
  • 10

1 Answers1

24

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>
gfinotti
  • 613
  • 5
  • 21