0

I was just wondering if there was a (non-js) solution to prevent "+", "-", "," , "." to be typed in an <input type="number"> in HTML5

Scipion
  • 11,449
  • 19
  • 74
  • 139

1 Answers1

2

You can see the solution of other question

<input type="text" onkeypress='return event.charCode >= 48 && event.charCode <= 57'>
</input>

I think the only solution is to control what key is pressed and only accent keys from 0 to 9, using their ASCII char code.

I have been researching a way to do only in HTML, but I haven't found anything that works in all browsers.

I don't know if this solution allow the using of backspace, but it would be as easy as include it in the onkeypress event

Community
  • 1
  • 1
Albert Lazaro de Lara
  • 2,540
  • 6
  • 26
  • 41