In javascript, You can use KeyPress Event also to find out the Char or digital.
For Example, (The following example will allow 0-9, a-z, A-Z, Underscore and
Dots in the UserName Text box in ASP.Net)
Place the following line in the Form_Load Function.
txtUserName.Attributes("onKeyPress") = "return chkUserNameKeyPress(event,'"
& txtUserName.ClientID & "')"
Place the following code in the Design form.
<script language=javascript>
function chkUserNameKeyPress(e,Id)
{
if(48 <= e.keyCode && 57 >= e.keyCode)
return true;
else if(97 <= e.keyCode && 122 >= e.keyCode)
return true;
else if(65 <= e.keyCode && 90 >= e.keyCode)
return true;
else if (e.keyCode == 46 || e.keyCode == 95 || e.keyCode ==
8)
return true;
else
return false;
}
I hope it will helps you.
with regards,
Murali