Cart Attribute required input fields aren't being required

Highlighted
New Member
1 0 1

Hi,

I used this doc to implement additional inputs on the cart, electing "required" in the UI Generator. I also got help from Shopify support to make the dropdown default to "Pick an option". There's one text input, and one dropdown, but neither are being required. Here's the code:

  <p class="cart-attribute__field">
    <label for="student-name">Student Name</label>
    <input required class="required" id="student-name" type="text" name="attributes[Student Name]" value="{{ cart.attributes["Student Name"] }}">
  </p>
  <p class="cart-attribute__field">
    <label>School</label>
    <select required class="required" id="school-building" name="attributes[School Building]">
      <option selected disabled="Elem-Middle School"{% if cart.attributes["School Building"] == "Elem-Middle School" %} selected{% endif %}>Select an option...</option>
      <option value="Elem-Middle School"{% if cart.attributes["School Building"] == "Middle School" %} selected{% endif %}>Elem. or Middle School</option>
      <option value="High School"{% if cart.attributes["School Building"] == "High School" %} selected{% endif %}>High School</option>
    </select>
  </p>

 

1 Like
Highlighted
New Member
1 0 0

I'm having the same problem. "required" works for line item properties, but not in the cart. any guidance here from shopify?

0 Likes
Highlighted
New Member
1 0 0

Same issue here. Hoping anyone can help out

0 Likes
Highlighted
New Member
2 0 0

https://community.shopify.com/c/Shopify-Design/Cart-Use-cart-attributes-to-collect-more-information/...

"6. If you set your form field to be required, then you will need to remove the novalidate attribute from the checkout form. Find novalidate, which is inside the opening <form> tag. ..."

Ran into the same problem and this worked for me, hope it helps. 

0 Likes