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

Limit input decimal places not working #32

Closed a0y1a closed 4 years ago

a0y1a commented 4 years ago

Digit Only input only allows three decimal places not working for me. I don't know what caused it.

See pictures below:

0 1

tonivj5 commented 4 years ago

@a0y1a, I have test it and it works (your pattern is correct)

I think that the problem comes from record.score. If it has 1.1234567, the input will reflect its value, although it's 'invalid'.

Have you fill the input by hand or it's the binded value?

a0y1a commented 4 years ago

The binded value is zero, then I change and fill the input by hand. According to my understanding, after I typed 1.123, if I go on typing 4, it should be prevented. Do I miss something or should I do something else to implement it ?

a0y1a commented 4 years ago

@tonivj5

changhuixu commented 4 years ago

Hi @a0y1a, I am not able to reproduce this problem. Please try this example in StackBlitz. I have tried Chrome, Edge, Firefox. All of them works, i.e., the input only allows 1.123.

I am afraid that you are using a different browser, but shouldn't matter, because keyboard event is almost generic across browsers. Another possible reason could be something like an iframe that prevents this directive act on your Angular module.

Anyway, you can start from the StackBlitz example, and work towards your component to see if you can reproduce the error.

a0y1a commented 4 years ago

@changhuixu Thanks for your feedback. I use Chrome. I tried example in StackBlitz, it works well. Then I copy the example in my project and run it in a new tab, it works not well. No error tips on chrome console. I will try to explore what causes this problem.

changhuixu commented 4 years ago

close this issue due to lack of reproducibility.