Making Cart Note Mandatory

Topic summary

A user is attempting to make the cart note field mandatory in their Shopify cart drawer but encountering issues. Despite adding the required attribute to both the checkbox and textarea elements in sections/theme__cart.liquid, the validation isn’t working—customers can still proceed without filling it out.

Current situation:

  • The required attribute appears correctly in the browser’s inspect tool
  • No novalidate attribute is present that would disable validation
  • The field can still be bypassed during checkout

Proposed solution:
A respondent suggests adding custom validation handlers to the textarea element:

  • oninvalid property to set a custom validation message
  • oninput property to clear the custom message when user starts typing

The issue appears to stem from HTML5 form validation not triggering properly, possibly due to how the cart drawer handles form submission or JavaScript interference.

Summarized with AI on November 3. AI used: claude-sonnet-4-5-20250929.

I’m trying to make the Cart Note field mandatory on the cart drawer.

I have added the “required” tag to both the checkbox and text input within the sections/theme__cart.liquid.

It is showing as “required” on the live site within inspect, and there is no “novalidate” anywhere I can see. However it is not making the field required, and you can simply bypass it.

Any help would be much appreciated.

Code snippet and a screenshot of the live site inspect below.

{% comment %} Cart notes {% endcomment %}
    {% if section.settings.main_enable_cart_note %} 
      <div
        class="
          border--b-width w-full p-4
          {{ section.settings.main_color_scheme_second }}
          {{ section.settings.main_color_border }}
        " 
        x-data="{ 
          reveal: cart.note != '', 
          currentNote: cart.note 
        }"
        x-show="cart.items.length > 0"
        x-cloak>
        <label class="flex items-center">
          <label  
            class="sr-only"
            for="notes">{{ 'actions.add_order_note' | t }}</label>
          <input
             required
            id="notes"
            class="" 
            type="checkbox" 
            :checked="reveal" 
            @click="reveal = ! reveal"
          >
          <p class="ml-2 text--small">{{ 'actions.add_order_note' | t }}</p>
        </label>
        <textarea
             required
          class="w-full mt-2"
          rows="4" 
          name="note"
          placeholder="{{ 'actions.message_placeholder' | t }}"
          x-show="reveal"
          x-model="currentNote"
          @keyup.debounce="updateCartNote(currentNote)"
          x-cloak>
        </textarea>
      </div>
    {% endif %}

Hi there add below code as properties into your textarea element

oninvalid="this.setCustomValidity('Please fill out this field')"
oninput="this.setCustomValidity('')"