JSFiddle - React, Tailwind, and code Playground
HTML
<input class="input-quantity" />
JavaScript
$(".input-quantity").keypress(function (e) {
return e.which >= ($(this).val().length ? 48 : 49) && e.which <= 57;
});
<input class="input-quantity" />
$(".input-quantity").keypress(function (e) {
return e.which >= ($(this).val().length ? 48 : 49) && e.which <= 57;
});