Hey, I have searched the entire Internet but unfortunately found nothing suitable. I want to make the fields “Name”, “How did you find us?”, “What is the reason for you inquiry?” and “Message” mandatory fields, where an error message pops up if they are not filled in. This is already standard for the “Email” field. But I can’t do it with the other fields, no matter if I write “required” in the “input” fields or other things I read in communities. I’ve been stuck on this for 6 hours now. Please help!
This is the HTML Code:
Show More
{{ ‘section-contact-form.css’ | asset_url | stylesheet_tag }} {%- style -%} .section-{{ section.id }}-padding { padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px; padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px; } @media screen and (min-width: 750px) { .section-{{ section.id }}-padding { padding-top: {{ section.settings.padding_top }}px; padding-bottom: {{ section.settings.padding_bottom }}px; } } {%- endstyle -%}
{%- if section.settings.heading != blank -%} ## {{ section.settings.heading | escape }} {%- else -%} ## {{ ‘templates.contact.form.title’ | t }} {%- endif -%} {%- form ‘contact’, id: ‘ContactForm’, class: ‘isolate’ -%} {%- if form.posted_successfully? -%} ## {% render ‘icon-success’ %} {{ ‘templates.contact.form.post_success’ | t }} {%- elsif form.errors -%} ## {% render ‘icon-error’ %} {{ ‘templates.contact.form.error_heading’ | t }}
- {{ form.errors.translated_fields.email | capitalize }} {{ form.errors.messages.email }}
{%- endif -%}
Show More
Show More
{%- if form.errors contains ‘email’ -%} {{ ‘accessibility.error’ | t }} {%- render ‘icon-error’ -%} {{- form.errors.translated_fields.email | capitalize }} {{ form.errors.messages.email -}} {%- endif -%}
Show More
Show More
Show More
Show More
{%- endform -%} {% schema %} { “name”: “t:sections.contact-form.name”, “tag”: “section”, “class”: “section”, “disabled_on”: { “groups”: [“header”, “footer”] }, “settings”: [ { “type”: “text”, “id”: “heading”, “default”: “Contact form”, “label”: “Heading” }, { “type”: “select”, “id”: “heading_size”, “options”: [ { “value”: “h2”, “label”: “t:sections.all.heading_size.options__1.label” }, { “value”: “h1”, “label”: “t:sections.all.heading_size.options__2.label” }, { “value”: “h0”, “label”: “t:sections.all.heading_size.options__3.label” } ], “default”: “h1”, “label”: “t:sections.all.heading_size.label” }, { “type”: “select”, “id”: “color_scheme”, “options”: [ { “value”: “accent-1”, “label”: “t:sections.all.colors.accent_1.label” }, { “value”: “accent-2”, “label”: “t:sections.all.colors.accent_2.label” }, { “value”: “background-1”, “label”: “t:sections.all.colors.background_1.label” }, { “value”: “background-2”, “label”: “t:sections.all.colors.background_2.label” }, { “value”: “inverse”, “label”: “t:sections.all.colors.inverse.label” } ], “default”: “background-1”, “label”: “t:sections.all.colors.label” }, { “type”: “header”, “content”: “t:sections.all.padding.section_padding_heading” }, { “type”: “range”, “id”: “padding_top”, “min”: 0, “max”: 100, “step”: 4, “unit”: “px”, “label”: “t:sections.all.padding.padding_top”, “default”: 36 }, { “type”: “range”, “id”: “padding_bottom”, “min”: 0, “max”: 100, “step”: 4, “unit”: “px”, “label”: “t:sections.all.padding.padding_bottom”, “default”: 36 } ], “presets”: [ { “name”: “t:sections.contact-form.presets.name” } ] } {% endschema %}
In Case u want to see it how it looks correctly, here is the CSS Code.
/* Custom Contact Form */
#ContactForm .field select {
position: initial;
width: 100%;
padding: 1.5rem;
line-height: calc(1 + .5 / var(--font-body-scale));
letter-spacing: .04rem;
background-color: rgb(var(--color-background));
color: rgb(var(--color-foreground));
font-size: 1.6rem;
font-family: var(--font-body-family);
font-style: var(--font-body-style);
font-weight: var(--font-body-weight);