Hi there.
I would like to add required and validation to name field in contact page like email.
Is there any way to add simply validation by liquid code base (Not by JS)
I added code like below but it doesn't validate name field.
<div class="grid__item medium-up--one-half">
<label for="{{ formId }}-name">{{ 'contact.form.name' | t }} <span aria-hidden="true">*</span></label>
<input
type="text"
id="{{ formId }}-name"
name="contact[name]"
value="{% if form.name %}{{ form.name }}{% elsif customer %}{{ customer.name }}{% endif %}"
aria-required="true"
{%- if form.errors contains 'body' -%}
class="input--error"
aria-invalid="true"
aria-describedby="{{ formId }}-name-error"
{%- endif -%}
>
{%- if form.errors contains 'body' -%}
<span id="{{ formId }}-name-error" class="input-error-message">
<span class="visually-hidden">{{ 'general.accessibility.error' | t }} </span>
{% include 'icon-error' %}
<span>{{ form.errors.translated_fields['name'] | capitalize }} {{ form.errors.messages['name'] }}.</span>
</span>
{%- endif -%}
</div>
I checked developers document but I could not understand how to implement it.
Thank you for your help.
User | Count |
---|---|
431 | |
200 | |
146 | |
57 | |
44 |