'I am trying to change the default promptCharacter in ngxMask in angular

I am using ngxmask in Angular to display the phone number in the following pattern:

(000) 000-0000

I set showMaskTyped Property to true to always display the mask pattern in the input which looks as the following:

(___) ___-____

I want to replace the _ with custom value # so that it looks like the following:

(###) ###-####

Here is the code:

<input mask="(000) 000-0000" [showMaskTyped]="true">

Here is the live example: https://jsdaddy.github.io/ngx-mask-page/mask-component#show-mask

What would be the best way to replace the default _ with #?



Solution 1:[1]

According to the documentation, placeHolderCharacter will allow you to override the default _.

In your case, you will do the following:

<input mask="(000) 000-0000" [showMaskTyped]="true" placeHolderCharacter="#" />

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 skouch2022