It works " /> It works " /> It works "/>

ngx-mask - truncated values from clipboard

78 views Asked by At

With the ngx-mask https://www.npmjs.com/package/ngx-mask , I'm trying to allow digits only up to 12.

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

It works properly in almost all cases, however if I paste the value "33 55" from the clipboard or similar, it truncates everything after space, so it pastes only "33".

How to fix this by pasting "3355" (no spaces - yes, but do not truncate the digits after the first space)?

1

There are 1 answers

0
fborges42 On

I'm facing the same situation. So far I haven't found an adapted solution to the library, however I found a way around it by using two "concurrent" masks.

In my scenario the mask +00 (0000) 000000000 would also truncate but adapting to +00 (0000) 000000000||+00 (0999) 099999999 does not.

I tested your scenario and this mask should solve it: https://stackblitz.com/edit/angular-masking-dynamics-apeepr?file=app%2Fapp.component.ts

000000000000||999999999999

My best guess is that it has to do with the way the library matches the optional values vs the required ones.