I have spent the last week trying to use masks on my Ionic 2 project inputs, since I’m a newbie with Angular2, I’ve tried to implement the masks using JQuery’s masked input libs, but on some smartphones the masked fields did not work.
Can somebody show me an example of an ionic2 project using CPF/CNPJ or any kind of mask working? Or only the relevant code and where I put it.
You can use this package: https://www.npmjs.com/package/ionic2-input-mask
Use the above mask for CPF, you can change it to fit in CNPJ too. private cpf = [/\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, '-' ,/\d/, /\d/];
Actually I’m using the br-masker-ionic-3, but it not possible to do this, or at least I don’t know how to…
I didn’t have any idea how to do it in a Ionic 3 app.
It is to display in a template view, after the input ID.
The goal is to put the correct mask on the view, doesn’t matter if the input is either CPF or CNPJ ID.
How to detect the correct input length and apply the correct mask on it.