changhuixu / ngx-digit-only

An Angular directive to only allow [0-9] in the input box when typing, pasting or drag/dropping.
https://changhuixu.github.io/ngx-digit-only/
MIT License
161 stars 70 forks source link

Allow for padding on mask #62

Open davija opened 2 years ago

davija commented 2 years ago

Currently, the pattern and mask seem to be very rigid...

It would be nice to define something like this:

What this should do (assuming my regex is correct) is allow for inputs of the following: 3/25 1/15 02/01 03/23

For some reason, most of these do NOT work.

02/01 - works 03/23 - works

Trying to type 3/25 yields -> 32/5 Trying to type 1/15 yields -> 11/5

Is there a way when the user types 3/ to force it to recognize that the user really means 03/?