<script type="text/javascript"> //Function to allow only numbers to textbox function validate(key) { //getting key code of pressed key var keycode = (key.which) ? key.which : key.keyCode; var phn = document.getElementById('txtPhn'); //comparing pressed keycodes if (!(keycode == 8 || keycode == 46) && (keycode < 48 || keycode > 57)) { return false; } else { //Condition to check textbox contains ten numbers or not if (phn.value.length < 10) { return true; } else { return false; } } } </script>
<asp:TextBox ID="txtTotal" runat="server" Width="131px" BorderStyle="None" Height="18px" onkeypress="return validate(event)"></asp:TextBox>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)