How to make a form field compulsory?

charlest4
Excursionist
25 0 3

Hi all,

 

I've been trying to find a way to make my custom form have a new compulsory field. Can't find anything online on how to do it!

 

Any help would be greatly appreciated!

 

Screenshot of form code:

Screenshot 2024-05-13 at 12.56.51.png

Reply 1 (1)

MaxDesign
Shopify Expert
213 15 83

Hi there,

You may just add the "required" attribute on the inputs you want to be compulsory. It's simple, check out this doc to have a few examples.

 

For instance: 

<div class="input—row">
  <label for="contactFormJCB">JCB VIN number:</label>
  <input type="text" id="contactFormJCB" name="[JCB serial number]" required />
</div>

 

Reach out to me at admin@maxdesign.expert