Search code examples
angularngx-mask

ngx-mask - Simple Decimal Mask Not working


I would like a textbox that allows only 2 decimals. I am using https://github.com/JsDaddy/ngx-mask/ to achieve this.

This example ( using Angular 8 and an older mask version ) works , but looks like the newer version doesnt!

This is my html:

<input type="text" mask="99999999999999.00">

Error repro :

https://stackblitz.com/edit/angular-ivy-mask-9g3gqs?file=src%2Fapp%2Fapp.component.html

enter image description here

NOTE: I have logged a defect in the repo, but was hoping someone in SO can also guide me in case Im missing something simple.


Solution

  • it is a bug coming from the package you can open the issue in GitHub,

    But for now you can use several workarounds.

    1. Use early versions of the package for example 8.2.x. The command for installing the old version of this package npm i [email protected]

    2. or use mask by this way

    <input type="text"  mask="separator.2" thousandSeparator="" separatorLimit="99999999999999">
    

    Here is the stackblitz example with the second solution https://stackblitz.com/edit/angular-ivy-mask-juzncf?file=src/app/app.component.html