Numeric TextBox (ASP.Net / HTML Input)
<
script language="javascript">function KeyCheck(e)
{
var KeyID = (window.event) ? event.keyCode : e.which;
if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47) ||
(KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126))
{
return false;
}
return true;
}
</
script> HTML Text Box
<
input type="text" ID="txt_TextBox" onkeypress="return KeyCheck(event);" runat="server" style="width: 28px" />
ASP.Net TextBox
<asp:TextBox ID="txt_ASPTextBox" runat="server" ></asp:TextBox>Code Behind for Asp.Net TextBox
txt_ASPTextBox.Attributes.Add("onkeypress","return KeyCheck(event);");
Comments