Shopify themes, liquid, logos, and UX
Looking to make the contact fields mandatory in Dawn 15.0. Thanks!
https://crosbyaudio.com/pages/contact
Solved! Go to the solution
This is an accepted solution.
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 <input> tag.
Here’s how you can modify your code:
In your case, for the "Name" field, it would look like this:
<div class="contact__fields">
<div class="field">
<input
class="field__input"
autocomplete="name"
type="text"
id="ContactForm-name"
name="contact[{{ 'templates.contact.form.name' | t }}]"
value="{% if form.name %}{{ form.name }}{% elsif customer %}{{ customer.name }}{% endif %}"
placeholder="{{ 'templates.contact.form.name'| t }}"
required
>
<label class="field__label" for="ContactForm-name">{{ 'templates.contact.form.name' | t }}</label>
</div>
<div class="field field--with-error">
...
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!!
B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.
B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.
B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.
BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now
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:
<input type="text" name="contact[name]" id="ContactFormName" placeholder="Name">
4. Make fields mandatory: Add the required attribute to each input field that you want to make mandatory. For example:
<input type="text" name="contact[name]" id="ContactFormName" placeholder="Name" required>
<input type="email" name="contact[email]" id="ContactFormEmail" placeholder="Email" required>
<textarea name="contact[body]" id="ContactFormMessage" placeholder="Message" required></textarea>
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!
B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.
B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.
B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.
BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now
My code looks different and I'm not sure where to add it.
<div class="contact__fields">
<div class="field">
<input
class="field__input"
autocomplete="name"
type="text"
id="ContactForm-name"
name="contact[{{ 'templates.contact.form.name' | t }}]"
value="{% if form.name %}{{ form.name }}{% elsif customer %}{{ customer.name }}{% endif %}"
placeholder="{{ 'templates.contact.form.name'| t }}"
>
<label class="field__label" for="ContactForm-name">{{ 'templates.contact.form.name' | t }}</label>
</div>
<div class="field field--with-error">
This is an accepted solution.
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 <input> tag.
Here’s how you can modify your code:
In your case, for the "Name" field, it would look like this:
<div class="contact__fields">
<div class="field">
<input
class="field__input"
autocomplete="name"
type="text"
id="ContactForm-name"
name="contact[{{ 'templates.contact.form.name' | t }}]"
value="{% if form.name %}{{ form.name }}{% elsif customer %}{{ customer.name }}{% endif %}"
placeholder="{{ 'templates.contact.form.name'| t }}"
required
>
<label class="field__label" for="ContactForm-name">{{ 'templates.contact.form.name' | t }}</label>
</div>
<div class="field field--with-error">
...
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!!
B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.
B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.
B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.
BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024