How to make a field required in a form

Highlighted
Tourist
6 0 0

This is not working for me either - I followed all of the steps on on here - https://help.shopify.com/en/themes/customization/cart/get-more-information-with-cart-attributes and selected the theme product.customizable  on the product page and it still is not required to add to cart and checkout...

 

<p class="cart-attribute__field" >
<label for="model">Model #</label>
<input required class="required" id="model" type="text" name="attributes[Model #]" value="{{ cart.attributes["Model #"] }}">
</p>

 

I found in a post with the supposed solution to the problem, follow the instructions and it didn't work for me.

 

Edit your product-customizable-template.liquid file (around line 143)

Change from this…. {% form 'product', product, class:form_classes, novalidate: 'novalidate' %}

To this… {% form 'product', product, class:form_classes:%}

Need to remove “nonvalidate” in order to be a required field

 

Please if someone could tell me how I could solve and make the field mandatory for checkout.

 

Thank you.

0 Likes
Highlighted

Please provide the link to your store. This will allow us to identify the exact issue.

My guess is you have an ajax cart. Meaning the items are being added to the cart through ajax and not through the normal form submission. Without getting too technical, this is probably why the required attribute in the <input> element is not working. You will need some custom coding to get the ajax to stop submission until the required fields are filled.

We work on Shopify stores to improve, maintain, and build functionality across all store types.
- Reach Out To Us! | hello@storemedics.com
- Visit Our Site! | https://www.storemedics.com

If we helped, leave a Like / Accept Solution
1 Like
Highlighted
Shopify Expert
1355 111 181

Please Provide Store url to better assist.

Thanks & Regards
Perennial Solution

Problem Solved?✔️Like and Accept the solution that can help others.
Need any help with theme customization or design? Hire us
Shopify Expert Page: https://experts.shopify.com/perennialsolution
Email: infoperennialsolution@gmail.com
Skype: infoperennialsolution
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing
1 Like
Highlighted
Tourist
6 0 0

Thank you very much for your prompt response.

 

My link is https://momentazo.myshopify.com/

In the catalog I have the products, the problem I have is that in the product the Nombre field and the Apellidos field must be mandatory and it is not working.

 

If you can help me, I would be very grateful.

0 Likes
Highlighted
Shopify Partner
1009 43 122

Dear dayaima,

 

You have missed "value="" required=""" in create account as well as  in products

 

Your code should be like this

 

<input type="text" id="ContactForm-name" name="contact[name]" value="" required="">

If you need more help then please contact here: https://www.task4store.com/pages/contact-us

Thanks & Regards
MS Web Designer
Get Free Store Audit Report
20000+ Task Completed
1000+ Satisfied Client
9.9*/10 Customer Rating
10*/10 Shopify Services Marketplace
1 Like
Tourist
6 0 0

Thank you



Please could you tell me how it works, where I have to add it.

0 Likes