I have a form used for entering retail close-out counts. I have already introduced code to limit the fields to just numbers, periods, and allow for back-space and tab. But some have complained that they accidentally hit the enter key when filling out the form, which submits it prematurely. I tried to lock out the enter key too, but it either killed the script altogether, allowing any key to type in the fields, or just flat out didn't work. Here is my working code. I tried adding an && event.which == 13, and even tried to put in another if statement with that but no avail. Ideas?
$(".allownumericwithdecimal").on("keypress keyup blur",function (event) {
if((event.which >= 48 && event.which <= 57) && event.shiftKey) {
event.preventDefault();
}
if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57) && event.which != 8 && event.which != 45 && event.keyCode != 9 ) {
event.preventDefault();
}
});