Everformat Product Options · Shopify how-to

How to limit characters in a Shopify personalization field

A personalization field needs limits that match what you can make: total characters, characters per line, which characters, and sometimes uppercase only. Here is what plain HTML can do and where it stops.

Method 1: maxlength and pattern (theme code)

  1. Add the field in a Custom Liquid block on the product page, in the Product information section.
  2. maxlength stops typing at a number of characters. pattern lists the characters you accept, and the browser blocks Add to cart if the text has anything else. title is the hint the browser shows.
  3. Test with an emoji and a curly apostrophe from a phone keyboard. This pattern rejects both, which is usually what an engraver wants, so say so next to the field.
{%- assign form_id = 'product-form-' | append: section.id -%}
<label for="text-{{ section.id }}">Personalization (20 characters)</label>
<input id="text-{{ section.id }}" type="text" name="properties[Personalization]"
  form="{{ form_id }}" maxlength="20" pattern="[A-Za-z0-9 .,'!?]*"
  title="Letters, numbers, spaces and . , ' ! ? only">

Where plain HTML stops

A textarea has maxlength but no pattern, and its maxlength counts the whole box, line breaks included. "2 lines of 15 characters" needs JavaScript.

CSS text-transform: uppercase only changes how the text looks. The order still gets what the shopper typed, in lowercase if that is how they typed it.

Shoppers cannot see how their text will lay out, so a long line that fits the limit can still surprise them.

Method 2: Everformat Product Options (no code, free)

  1. Install Everformat Product Options from the Shopify App Store and click Turn on automatic embed.
  2. For a simple limit, add a text field and set Maximum characters.
  3. For engraving-style limits, tick Engraving rules on the field. Choose 1 to 4 lines, characters per line, and allowed characters: letters only, letters and numbers, letters, numbers and basic punctuation, or only the characters you list.
  4. Tick Engrave in UPPERCASE if you need it. The order gets the uppercase text, not just an uppercase look.
  5. Shoppers see a live preview of exactly what will be saved, one row per line with a character count, and Add to cart waits until every line fits.

Everformat Product Options is our Shopify app for this. The Free plan covers 3 option sets with up to 10 fields each.

Get it on the Shopify App Store About the app

Questions

Are engraving rules on the Free plan?

Yes. Line limits, allowed characters, UPPERCASE and the live preview are all free.

How are emoji counted?

The browser’s maxlength can count one emoji as two characters. With the app, an allowed characters rule rejects emoji entirely, so the count never surprises anyone.

More guides