I have date inputs in my cart page I would like to use JavaScript to validate this correct dates when the checkout button is clicked on cart page, how do I do this on the horizon theme, the new theme seems to be very much complicated
Hey @PAULEO ,
Could you please share the store URL so that I can take a look and provide you with the solution code.
Thanks
You can do these steps:
Prevent the checkout button from submitting if date fields are invalid
Validate custom inputs (like a date input) on the cart page
Work within the Horizon theme structure
Please select a valid date.
Paste this at the bottom of your cart.liquid or in the custom JavaScript section of the cart page:
HI, Unfortunately this did not work. I don’t know if there is some other JavaScript code or code blocking/overriding the event listener or Preventdefault.
Hi @PAULEO
that is an advanced theme customization and keep in mind that checking dates&time in the customers browser is fragile and not to be trusted.
So more complicated to add an api for the true time.
If you do know how to work with dates in javascript then look at any customizations that disable checkout for things like terms-of-service checkboxes, age-gates, or required delivery dates etc.
If you need this customization then contact me for services.
Contact info in forum signature below
.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.