How to make a field required on cart page

Hi Cirara,

This can be a little tricky depending on how your theme is structured and which date picker you’re using.

If you have some Javascript knowledge, your best bet would be to add an event listener to the on the cart page, and run some validation when the form is submitted.

That is how we provide this option with our Bloom date picker app. The code would be something like:

document.body.addEventListener("submit", function (e) {
  if (e.target.getAttribute("action") === "/cart") {
    if (document.querySelector('#ID-OF-DATEPICKER-FIELD').value === "") {
      e.preventDefault();
      e.stopPropagation();
      alert("Please select a delivery date");
      return false;
    }
  }
});

This should work for pretty much every theme.

Hope this helps! Best of luck.