-1

This solution works perfectly in all browsers and this is very easy use.

  1. This is work without Numpad.

onkeydown = "return (!(event.keyCode>=65) && event.keyCode!=32);"

  1. This is work with Numpad.

onkeydown = "return (!((event.keyCode>=65 && event.keyCode <= 95) || event.keyCode >= 106) && event.keyCode!=32);"

1 Answers1

0

I think this is best way

<input type="number" name="txtNum" />

No script required.

Imad
  • 7,126
  • 12
  • 55
  • 112
  • Good. But I think this is best for HTML5. For the ASP.net I think that one practice is good. Thank you for your idea. – Lahiru Supunchandra Jun 12 '17 at 06:43
  • You should have learn't that aspx engine is built upon basic html, hence everything that is supported by html is also supported by aspx engine. – Imad Jun 12 '17 at 07:05