If you have a text box, you need to handle the event onkeypress
<input type='text' onkeypress='keypresshandler(event)' />
You can use the following function to restrict users
function keypresshandler(event)
{
var charCode = event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
}
source
share