0

I want to exclude the "Enter"(keycode 13) key on Android when a user selects a quantity but I need to still have him able to remove a quantity(keycode 8).

<input type="number" name="quantity" value="<?php echo $this->request-
>quantity; ?>" size="3" onkeypress="return event.charCode <= 57" 
maxlength="3"/>

I tried using "&& event.charCode !=13" or selecting each number individually with the == operator but it doesn't work, should I create a condition or could I use javascript to intercept the charCode 13 when used?

1 Answers1

0

I found a solution with :

<input type="number" name="quantity" value="<?php echo $this->request-
>quantity; ?>" size="3" onkeydown='return (event.which >= 48 && event.which <= 
57) || event.which == 8 || event.which == 46' required />

Thanks to Only allow numbers, backspace and delete keys on input text