Monday, August 10, 2009

Javascript to Allow only numbers in TextBox

Javascript to Allow only numbers in TextBox
======================================



function CheckKeyCode(e)
{
if (navigator.appName == "Microsoft Internet Explorer")
{
if((e.keyCode >= 48 && e.keyCode = 48 && e.charCode <= 57) || (e.charCode == 0))
{
return true;
}
else
{
return false;
}
}
}



// Add this code in your GridView control's RowDataBound Event.

((TextBox)e.Row.FindControl("txtDispOrder")).Attributes.Add("onkeypress", "javascript:return CheckKeyCode(event);");

No comments: