I wan't to know how to set a max length for the Qty field that is when you click a product (I guess it's product View) I tried to override the following template and set maxlength = "4" but did not work.


What template should I override or what item can I modify in the layout to allow just 4 digits in Qty field?


1 Answer 1


What you're describing is a limitation of the html 5 element, not of Magento or your process. That is indeed the location you would need to change, and when I make the edit you described I see it on my front-end when I view source. The problem you're describing is that the input type "number" ignores maxlength.

There are solutions at this thread on regular stack overflow. I wouldn't recommend changing the field to text (although this would work) because it breaks the mobile experience. There are some simple javascript validation techniques described at that link.

  • Thank you! as you said it was because of the number type. I used js now it works Aug 22, 2019 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.