How to prevent cart quantity input abuse in online stores?

Hi,

does anyone have a solution for fixing the quantity order abuse?

Customers can change the quantity in the cart to 99999, and it will automatically update and change the quantity to the amount that is in your inventory. I’ve tried to fix this bug by changing some code, but it doesn’t work.

HTML I’ve added into the quantity input field:

min=“0” max=“5” maxlength=‘1’ pattern=“[0-5]*”

Sadly this still doesn’t work because you can type in the numbers.

Any solutions?

You can use the “onchange” event and then set the value if the input exceeds your max.

Demo here: https://jsfiddle.net/70Lpnkz2/20/