Looking to make the contact fields mandatory in Dawn 15.0. Thanks!
Topic summary
A user seeks to make contact form fields mandatory in Shopify’s Dawn theme version 15.0.
Solution Provided:
- Navigate to Shopify Admin → Online Store → Themes → Edit code
- Locate the contact form file in the Sections folder (typically
contact-form.liquidormain-contact.liquid) - Add the
requiredattribute to each<input>tag that should be mandatory
Implementation:
For the name field example, modify the input tag to include required within the opening tag. This same approach applies to other fields like email, phone, or message (<textarea>).
Current Status:
The user shared their existing code structure, which differs slightly from the initial example. The support team confirmed the same method applies: simply insert the required attribute into each relevant input or textarea tag to enforce mandatory field validation.
The discussion remains open as implementation is in progress.
Hi @crosbyaudio ,
To make the contact form fields mandatory in the Dawn theme (version 15.0), you can do this by modifying the form code. Here’s how you can implement this:
- Go to your Shopify Admin:
- Navigate to Online Store > Themes.
- Find your Dawn theme and click Actions > Edit code.1. Locate the contact form code: In the Sections folder, find and click on contact-form.liquid (or main-contact.liquid).
- Add " required " attributes: Find the input fields for the contact form. These fields usually look like this:
- Make fields mandatory: Add the required attribute to each input field that you want to make mandatory. For example:
Save the changes: Click Save to apply the changes.
I hope these instructions will help you. If they are helpful, please give us likes and mark as the solution.
Have a nice day sir!
My code looks different and I’m not sure where to add it.
Hi @crosbyaudio ,
Thanks for share your code.
To make fields mandatory in this version of the contact form, you just need to add the required attribute to each relevant tag.
Here’s how you can modify your code:
- Locate the input tag in each field section.
- Add the required attribute inside the input tag.
In your case, for the “Name” field, it would look like this:
...
Do this for each field you want to make mandatory by adding the required attribute to the corresponding input or textarea tag.
Hope it helps!!