0

Previously when it was specified, Magento used to honor the max character length for custom input fields, so if I set that to two characters (for initials), it would not let the customer type in more than two characters.

Now I see that even though the note underneath the text field still says maximum two characters allowed, I can type in as many characters as I want. Anyone know how to troubleshoot such problem, I checked my browsers console and see no JavaScript errors being thrown there, any help is welcome.

Thanks in advance!

0

Default magento not provide character limit while typing in custom option text box so we can use jquey using below code

$(document).ready(function() { $(".product-options input").attr('maxlength','3'); });

you need set character limit. Replace 3 with your character limit number.

i hope it will be helpful for you !!

  • Hi, thank you for the answer, but that will not work for us because we have more than one textfield and only one needs to have a size restriction. – K.I Mar 28 '17 at 9:07
  • Ok then you can use input position if its first then use input:first-child if other then use input:nth-child(n) if its last then use input:last-child . Just replace input with input and its position. – Mukesh Prajapati Mar 28 '17 at 11:23
  • I had to make some changes to this suggestion to make it work, because when I used input:first-child or :nth-child it was setting restrictions either to all textfields or not setting them at all. I used input:eq(n) instead and that let me select second value and only add character restrictions on that variable. – K.I Apr 4 '17 at 16:53
  • This is your answer jQuery( document ).ready(function() { jQuery(".input-box input:eq(1)").attr('maxlength','3') }); its working for second input box @K.I – Mukesh Prajapati Apr 5 '17 at 6:43

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.