I have searched in web two days how to validate checkout fields without any luck. All the research I have made have risen some questions because tutorials I have found are all about custom-form validation.

When I add additional fields to checkout step below or before shipping-method, inside already existing form and I want to validate them to be required. Can I add only the fields needed or should I add the fields with form element? All the tutorials and Magento 2 official documentation are teaching to validate forms but no where is any reason why forms should be used?

Is it even possible to validated single input field inside Magento already existing form? I know I can add input fields without form and get the information in admin section without any issues if the field can be left blank but otherwise.

Example: I add the input field inside shipping method form below the radio buttons as additional field and I want alert to be raised when customer has not filled the field when next button is clicked?

Additional questions (not required): Can anyone suggest steps I should make to find out(debug...) how Magento 2 denies customer to go on, if required fields are not filled? I have tried chrome dev-tools, but i am beginner using it. How to find last executed if statement (based on assumption)?

Your Answer

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

Browse other questions tagged or ask your own question.