Remove email input from contact form

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:

{{ 'templates.contact.form.email' | t }} * {%- if form.errors contains 'email' -%} {{ 'accessibility.error' | t }} {% render 'icon-error' %}{{ form.errors.translated_fields['email'] | capitalize }} {{ form.errors.messages['email'] }} {%- endif -%}

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?

1 Like

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:


  
  

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


  1. 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.

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’ %}

{{ ‘accessibility.error’ | t }}
{% render ‘icon-error’ %}{{ form.errors.translated_fields[‘email’] | capitalize }} {{ form.errors.messages[‘email’] }}


{% 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.

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

Though I commented all the code with email

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

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

Any luck on this?