If you're using ASP.NET 4.0 or later, you just need to add
type="number"
to your
TextBox
:
<asp:TextBox runat="server" type="number" />
This will render a numeric input type:
http://www.html5tutorial.info/html5-number.php[
^]
It's supported in all modern browsers:
http://caniuse.com/#feat=input-number[
^]
If you need to support older browsers, there is a polyfill available:
https://github.com/jonstipe/number-polyfill[
^]
This has the added benefit that, on mobile devices, the user will see the numeric keyboard by default when they tap on the input.