I have the following code. I want to validate just numeric only.
$('.numericonly').keypress(function (e) {
var regex = new RegExp("^[0-9]+$");
var str = String.fromCharCode(!e.charCode ? e.which : e.charCode);
if (regex.test(str)) {
return true;
}
e.preventDefault();
return false;
});
When I use above code, backspace and tab doesn't work anymore. Can anyone help me to enable backspace and tab?