How to allow only integers in a textbox or Allow only numeric value ( numbers ) in TextBox using JavaScript or Allow only numeric values to be entered in a textbox using JavaScript in Asp.net
<head><script language="javascript" type="text/javascript">
function CheckNumeric(e) {
if (window.event) // IE
{
if ((e.keyCode < 48 || e.keyCode > 57) & e.keyCode != 8) {
event.returnValue = false;
return false;
}
}
else { // Fire Fox
if ((e.which < 48 || e.which > 57) & e.which != 8) {
e.preventDefault();
return false;
}
}
}
</script>
</head>
<body><table>
<tr>
<td>
<strong>Mobile No</strong>
</td>
<td>
<asp:TextBox ID="txtMobile" runat="server" Height="23px" Width="246px"
onkeypress="CheckNumeric(event);" MaxLength="11"></asp:TextBox>
</td>
</tr>
</table>
</body>