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 71 forks source link

keyboard event doesn't properly handle input selection for decimal numbers #39

Closed changhuixu closed 4 years ago

changhuixu commented 4 years ago

For an input element,

<input
      id="dollar-amount"
      type="text"
      name="dollar-amount"
      inputmode="numeric"
      pattern="^(?=.*\d)\d*(\.\d{1,2})?$"
      placeholder="0.00"
      digitOnly
      decimal="true"
    />

If enter 1.35, select all, then enter .25. The input box will have value 25, which is not correct.