Changing the maxlength attribute in the checkout form fields

alextorresalextorres Member
Hello,

I saw this on the changes for v2.0: "Updating checkout address templates to include maxlength values."

and I see the attribute in the fields maxlength="50" for example in the "shipping_first_name" field.

is there a way I can modify this value? I've searched the forums and the documentation but couldn't find anything on how to do this.

Thanks!
Tagged:
Comments
  • marijamarija FoxyCart Team
    Hi @alextorres -

    Thanks for reaching out! The change for v2.0 restricts the maxlength values to coincide with our database value lengths, so unfortunately, it can't be changed.

    Please let us know if you have any additional questions.

    Best,
    Marija

  • Hello @marija

    my intention was to lower the maxlength to 30, so the database value lengths wouldn't be a problem. But I'm guessing it's still not possible.

    Thank you for the answer!
  • fc_adamfc_adam FoxyCart Team
    @alextorres,

    Thanks for confirming - it is actually possible to go lower there if you want. For setting the shipping first name, you could do that with javascript added to the "footer" textarea of the "Add custom header and footer code to your templates" option. You can find that option on the "configuration" page of your store's FoxyCart administration:
    {% if context == "checkout" %}
    <script>
    FC.client.on("render.done", function() {
    $('#shipping_first_name').attr("maxlength","30");
    });
    </script>
    {% endif %}
    You can then expand on that to also then alter down other maxlength attributes as needed.
  • Hello @fc_adam,

    this does exactly what I needed, thank you
Sign In or Register to comment.