I've written a very simple class selector so that I can make html input boxes only accept numeric inputs
$(".numericOnly").keypress(function (e) {
if (e.keyCode == 13) return true;
if (String.fromCharCode(e.keyCode).match(/[^0-9]/g))
return false;
});
Then, if you have an input box, you just assign it class="numericOnly" and it will only accept numeric input.
keyCode 13 is the enter key, which prevents the function from intercepting and blocking it.
It works great in Chrome and oddly in IE 9, but it fails in firefox. Not sure why. There are no errors being thrown.