This feature is powered by IMask js.
See the full guide https://imask.js.org/guide.html.
To use mask, provide inputMask
. Some adjustment need to be made when the config is JSON. Checkout JSON compatibility below.
{
"formControlName": "...",
"inputMask": {
"mask": "^\\D+$"
}
}
{
formControlName: "...",
inputMask: {
mask: /^\D+$/
}
}
Only
text
type is supported when using mask. Hence, thetype
value will be ignored and automatically usetext
wheninputMask
is present.
When config is JSON, some features are not available. There are few adjustments need to be made when provide the config in JSON.
Regex need to be pass as string literal and all \
characters need to be escaped.
Example: /^\d+$/
⇒ ^\\d+$
The following value of the mask
must be stringified:
Original | Stringified |
---|---|
Number | “Number” |
Imask.MaskedRange | “Imask.MaskedRange” |