Asp.Net Textbox Numeric Only From Javascript

Write The folloeing Javascript

function NumericOnly()
{
var key = window.event.keyCode;
if((key < 46 || key > 57))//|| key != 46)
window.event.returnValue = false;
}

And Call  NumericOnly() javascript funvtion on  Key Press of TextBox

<asp:TextBox ID=”txtPhone” runat=”server” OnKeyPress=”NumericOnly()” MaxLength=”14″></asp:TextBox>

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s