I have a div that is dynamically loaded to my page using an ajax request. In this div, I have several inputs with the same class, but with different identifiers
These inputs have a keyup function, a keystroke function, and an onblur function.
The problem is that I want the user to be able to enter numbers and use the TAB.
I use this function here
function validatenum(event) {
var key = window.event ? event.keyCode : event.which;
if (event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 46
|| event.keyCode == 37 || event.keyCode == 39
) {
return true;
} else if (key < 48 || key > 57) {
return false;
} else {
return true;
}
}
and I call it with:
<input type="text" id="31_w_pr" class="order_sizes"
onkeypress="validatenum(event);" />
But that will not work. I can enter whatever I want.
Does anyone have an idea how to fix this?
thank
source
share