I have the following code:
function noNumbers(e)
{
var charCode = (e.which) ? e.which :
((e.charCode) ? e.charCode :
((
This works for me on Firefox.
var keycodes = {
'backspace': 8,
'delete': 46,
'leftArrow': 37,
'rightArrow': 39,
'number1': 48,
'number9': 57
};
function noNumbers(e)
{
var charCode = e.which ? e.which :
(e.charCode ? e.charCode :
(e.keyCode ? e.keyCode : 0));
if ((charCode < keycodes.number1 || charCode > keycodes.number9) &&
charCode !== keycodes.delete &&
charCode !== keycodes.backspace &&
charCode !== keycodes.leftArrow &&
charCode !== keycodes.rightArrow)
e.preventDefault();
}
document.getElementById('noNum').addEventListener(
'keypress', noNumbers
);