Thursday, July 23, 2009

Enter only digits in Textbox

The following code snippet allows user to enter only digits.

function AcceptDigits(e)
{
var charCode = (navigator.appName == "Netscape")? e.which : e.keyCode;
if(e.shiftKey)
{
return false;
}
if( (charCode > 47 && charCode < 59) || charCode==8 || charCode==37 || charCode==39 || charCode==46 || charCode==9 || charCode==36 || charCode==35)
{
return true;
}
else
{
return false;
}
}

No comments:

Post a Comment