How do you mask a decimal with optional integer ngx-mask

2.1k views Asked by At

I'm working with ngx-mask v11.1.5 and am having difficulty creating a mask that allows both leading integers and omitted integers. For instance, both ".5" and "0.5" should be acceptable inputs and set the model to "0.5".

I've tried using the mask 9*.0*, since 9* should be 0 or more digits, but when testing with leading digits, I could not enter a decimal, and when testing without leading digits, I could not enter the trailing digits.

1

There are 1 answers

0
vball On

I realized that it is not necessary to use a mask here. Initially I was using masks to conditionally prevent decimals (0*) on text inputs. In order to allow decimals I just conditionally switch the input to type="number" and disable the mask