Re: Remove email input from contact form

Remove email input from contact form

Ksu10005
Excursionist
21 0 3

Hi everyone!
I'm using Dawn theme and I want to remove Email input from the contact form. 
I removed this part of my code in contact-form.liquid file:

<div class="field field--with-error">
<input
autocomplete="email"
type="email"
id="ContactForm-email"
class="field__input"
name="contact[email]"
spellcheck="false"
autocapitalize="off"
value="{% if form.email %}{{ form.email }}{% elsif customer %}{{ customer.email }}{% endif %}"
aria-required="true"
{% if form.errors contains 'email' %}
aria-invalid="true"
aria-describedby="ContactForm-email-error"
{% endif %}
placeholder="{{ 'templates.contact.form.email' | t }}"
>
<label class="field__label" for="ContactForm-email">{{ 'templates.contact.form.email' | t }} <span aria-hidden="true">*</span></label>
{%- if form.errors contains 'email' -%}
<small class="contact__field-error" id="ContactForm-email-error">
<span class="visually-hidden">{{ 'accessibility.error' | t }}</span>
<span class="form__message">{% render 'icon-error' %}{{ form.errors.translated_fields['email'] | capitalize }} {{ form.errors.messages['email'] }}</span>
</small>
{%- endif -%}
</div>

And email input was really removed from my contact from, but still when I send Name and phone in my contact form it's written "invalid email". 
How can I solve it?

Replies 6 (6)

ZestardTech
Shopify Partner
6096 1091 1464

Hello @Ksu10005 

You can modify the contact-form.liquid file. Here's how you can do it:

1.Locate the contact-form.liquid file in your theme's code editor.
2.Find the code that represents the email input field. It may look similar to this:

<div class="form__group">
  <label for="ContactFormEmail" class="form__label">{{ 'contact.form.email' | t }}</label>
  <input type="email" id="ContactFormEmail" name="contact[email]" class="form__input" value="{{ contact.email }}" required>
</div>

3.Remove the entire code block representing the email input field. After removing it, the code should look like this:

<!-- Removed email input field -->

 

4. Save the changes to the contact-form.liquid file.

By removing the email input field from the contact-form.liquid file, the email field will no longer be displayed in the contact form on your website.



Want to modify or develop new app, Hire us.
If helpful then please Like and Accept Solution .
Email: support@zestard.com
Shopify Apps URL :- https://apps.shopify.com/partners/zestard-technologies
Custom Modifications Into Shopify Theme | Shopify Private App | SEO & Digital Marketing

magecomp
Shopify Partner
458 31 47

Hello @Ksu10005 

 

The reason why you are still getting an error message about an invalid email address even though you have removed the email input from your contact form is because the email validation logic is still in place.

To fix this, you need to remove the email validation logic from your contact form. You can do this by editing the contact-form.liquid file and removing the following code:

{% if form.errors contains 'email' %}
<small class="contact__field-error" id="ContactForm-email-error">
<span class="visually-hidden">{{ 'accessibility.error' | t }}</span>
<span class="form__message">{% render 'icon-error' %}{{ form.errors.translated_fields['email'] | capitalize }} {{ form.errors.messages['email'] }}
</span>
</small>
{% endif %}

Once you have removed this code, you should no longer get an error message about an invalid email address when you submit your contact form without an email address.

Helping voluntarily. Please like and accept the solution if it helps. Thanks!
Our Bestseller Shopify Apps    |      Mobile App Builder by MageComp    |      Shoplock Hide Pages/Collections

Need a developer?  Just visit MageComp website
Ksu10005
Excursionist
21 0 3

Hello @magecomp 
I did it, but it still shows me Email is invalid

Though I commented all the code with email

Снимок экрана 2023-05-23 в 17.38.58.png

thethninaye
New Member
4 0 0

I am also trying to do the same. Have you succeeded in doing so? If so, could you share the solution? 

Felipe_Pontes_G
Shopify Partner
3 0 5

This only removes the error message. The validation is still there.

Jayeshvaru
Shopify Partner
1 0 0

Any luck on this?