Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 8
    I feel like this is a much more robust (and simpler) solution than the accepted answer. Commented Oct 2, 2015 at 15:51
  • Even simpler if using replace(/\D/g, '') Commented Jan 21, 2016 at 16:32
  • hi, how can I ensure numeric value with a decimal between 0.0 to 24.0 I am unable to let it enter the . Commented Apr 2, 2017 at 0:30
  • 1
    I would suggest using this.value = Number(this.value.replace(/\D/g, '')); Commented Aug 28, 2018 at 21:47
  • Good answer, allows to easily toggle whether an input is numeric or not by toggling class Commented Jan 25, 2019 at 10:23