How can i get ngx-mask masked value?
Asked Answered
L

1

13

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

Lambdoid answered 13/3, 2020 at 8:26 Comment(0)
S
30

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>
Schreibman answered 8/5, 2020 at 13:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.