How to make the email field required in a contact form code?

How to make the email field required in a contact form code?

PreciousU
Excursionist
14 0 1

I'm trying to make the email field on the contact form required. I was trying to enter the code below but my error is that I didn't tell the aria what to do from what I understand. Does anyone know how I can correct the code?

 

 

          <div class="grid__item medium-up--one-half">
            <label for="ContactFormEmail" class="label--hidden">{{ 'contact.form.email' | t }}</label>
            <input type="email" id="ContactFormEmail" name="contact[email]" placeholder="{{ 'contact.form.email' | t }}" autocorrect="off" autocapitalize="off" value="{% if form.email %}{{ form.email }}{% elsif customer %}{{ customer.email }}{% endif %}"
                aria-required="true"
                   {% if form.errors contains 'email'%}
                   class="input--error"
                   aria-invalid="true"
                   aria-describedby="{{ FormId }}-email-error"                   
                   {%end if%}
                   >
            
          
          </div>
        </div>

 

Reply 1 (1)

LitExtension
Shopify Partner
4860 1002 1160

Hi @PreciousU,

You just need to add 'required' to the input, it will work fine.

Screenshot.png

Hope it helps!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify