0

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.

magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml

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

Thanks!

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.

| improve this answer | |
  • Thank you! as you said it was because of the number type. I used js now it works – Oscar Vazquez Aug 22 '19 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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