Javascript code:
Textbox:
<script language="Javascript" type="text/javascript"> function onlyNos(e, t) { try { if (window.event) { var charCode = window.event.keyCode; } else if (e) { var charCode = e.which; } else { return true; } if (charCode > 31 && (charCode < 48 || charCode > 57)) { if (charCode === 46) return true; else return false; } return true; } catch (err) { alert(err.Description); } } </script>
Textbox:
<asp:TextBox ID="txtNumbersOnly" runat="server" onkeypress="return onlyNos(event,this);" Width="146px" CssClass="rightinput"></asp:TextBox>