You will find some good options here:
jQuery: what is the best way to restrict “number”-only input for textboxes?[
^]
EDIT:
Code Example
I do some code like you applied there and find it is working good for 2 textboxes that accepts only 6 digit numbers, hope it would be helpful for you. See:
<script type="text/javascript">
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
} else {
return true;
}
}
</script>
<asp:TextBox ID="TextBox1" runat="server" MaxLength="6" onkeypress="return isNumberKey(event)"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" MaxLength="6" onkeypress="return isNumberKey(event)"></asp:TextBox>