<asp:TextBox ID="txt_tenderno" onkeydown="return onKeyPressBlockNumbers(event)" onFocus="this.style.background ='yellow'" onBlur="this.style.background='white'" runat="server" ></asp:TextBox>
function onKeyPressBlockNumbers(e)
{
var key = window.event ? e.keyCode : e.which;
var keychar = String.fromCharCode(key);
reg = /\d/;
return !reg.test(keychar);
}
-----------------OR---------------------
<asp:TextBox ID="txt_tenderno" onkeydown="return numeric(event)" onFocus="this.style.background ='yellow'" onBlur="this.style.background='white'" runat="server" ></asp:TextBox>
function numeric(e) {
var key = window.event ? e.keyCode : e.which;
return ((key == 8) || (key > 47 && key < 58));
}
No comments:
Post a Comment