<asp:TextBox ID="txtCloseReading" runat="server" attr-identity="CloseReading" MaxLength="10" CausesValidation="true" oncopy="return false" onpaste="return false" onkeypress="return NumberKeyAndDotKey(this.value,event);"></asp:TextBox>
function NumberKeyAndDotKey(StringValue, evt) { var status = false; var charCode = (evt.which) ? evt.which : event.keyCode; if (charCode == '46' || (charCode >= '48' && charCode <= '57')) { status = true; if (contains(StringValue, '.')) { if( (charCode >= '48' && charCode <= '57')) { status = true; } else { status = false; } } } return status; }
<asp:TextBox ID="txtCloseReading" runat="server" attr-identity="CloseReading" MaxLength="10" CausesValidation="true"oncopy="return false" onpaste="return false"></asp:TextBox>
$('#txtCloseReading').keypress(function (e) { if ((e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) && e.which != 46) { return false; } });
if (charCode == '8' || charCode == '46' || (charCode >= '48' && charCode <= '57'))
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)