Thursday, October 13, 2011

Validate Number by Javascript function

by this function simply call this function on onkeypress event and get mast functionality.
function isNumberKey(e) {
var charCode = (e.which) ? e.which : event.keyCode
if ((charCode > 31) && (charCode < 48 || charCode > 57)) {
return false;
}
}

//call on onkeypress event in textbox

asp:TextBox ID="txtbox1" runat="server" CssClass="input_big" MaxLength="15"
onkeypress="return isNumberKey(event)"/asp:TextBox

No comments:

Post a Comment