Validate quantity selector and text area input

Topic summary

A Shopify merchant using the Dawn theme needs client-side validation that ensures the number of label names entered in a text area matches the quantity selected before allowing Add to Cart.

  • Context: Product page has a quantity selector and a text area where customers list label names corresponding to the quantity. Dawn is Shopify’s default theme.
  • Problem: Customers sometimes enter fewer or more names than the selected quantity (e.g., select 5 but list 4 or 6). The poster can count entries in the text area but is struggling to validate this against the quantity selector value.
  • Desired behavior: On clicking Add to Cart, compare the text area count with the selected quantity and only proceed if they are identical; otherwise prevent adding to cart.
  • Artifacts: A screenshot illustrates the UI with the quantity selector and text area; helpful for understanding layout but not strictly required.
  • Status: No solution or code provided yet; seeking implementation guidance. Discussion remains open.
Summarized with AI on January 24. AI used: gpt-5.

Hi all.

I am using the Dawn theme. And on a specific product I have a quantity selector and a text area where a user can list the label names they want based on the quantity they selected (see screenshot below). I would like a way to validate the quantity selected to ensure that it corresponds to the number of listed labels.

I can write a script that can count the number of listed labels in the text area, but I am struggling to find a way to validate it with the count on the quantity selector. The reason for this validation is because we are having challenges where our customers may list “more than” or “fewer than” the label quantity number they specified in the quantity selector. For example, they may choose they want 5 labels, but write only four label names or write 6 label names in the text area.

So I would like the validation to occur when the “Add to Cart” button is clicked to ensure that the labels are only added to cart if the quantities are identical.

Any help will be most appreciated.