I already success adding an input for delivery date in checkout page based on this link. But, the problem is, customer still can skip the input, and click next to finish the order. How can i made it required and customer should fill it before click next? I already tried to add required in the input but it's not work.


Try to add the below code inside your input tag:



<input type="text" data-validate="{required:true}" class="background-none"  value="" name="registrant[0][firstname]" title="<?php echo __("First Name")  ?>" id="firstName" class="input-text required-entry">

Hope it help you!

  • No it's not work, though it's not that simple to only adding data-validate="{required:true}" Nov 15 '17 at 2:11
  • How do you insert you template? Use reference in XML file (Layout) or just insert your templte? Maybe your input is not inside the <form> tag so it doesn't take required. Please post what layout you reference and the .phtml file you added.
    – Nero Phung
    Nov 15 '17 at 2:14
  • You could check the link that i add in my question, it's all the same with my case. Nov 15 '17 at 2:45
  • Try add <div class="field required"> outside the input. If It doesn't work, maybe you have to add custom js code to handle when click to Next button. I'm not sure.
    – Nero Phung
    Nov 15 '17 at 2:54
  • Found it, in \vendor\magento\module-checkout\view\frontend\web\template\shipping.html, there's novalidate="novalidate" in the form that made the required not work. Thank you for helping to find the answer. Nov 15 '17 at 3:16

You can set attribute value with "readonly" and set custom validation using jQuery to not proceed if not selected date value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.