Hi, I need to add a field for customers when they register to enter their birthday because I my products are 18+.
So in total i have two problems.
Problem 1: This field should be REQUIRED, but everything I do it I wont get it to be required.
Current code:
#
{{ 'customer.register.title' | t }}
{%- form 'create_customer', novalidate: 'novalidate' -%}
{%- if form.errors -%}
##
{{ 'templates.contact.form.error_heading' | t }}
{%- for field in form.errors -%}
- {%- if field == 'form' -%}
{{ form.errors.messages[field] }}
{%- else -%}
{{ form.errors.translated_fields[field] | capitalize }}
{{ form.errors.messages[field] }}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- if form.errors contains 'email' -%}
{{ form.errors.translated_fields.email | capitalize }}
{{ form.errors.messages.email }}.
{%- endif -%}
{%- if form.errors contains 'password' -%}
{{ form.errors.translated_fields.password | capitalize }}
{{ form.errors.messages.password }}.
{%- endif -%}
{%- endform -%}
At the bottom is the birthday field. I tested, if I enter a bithday and hit submit I can see the birthday in the customer overview.
But I can also press submit if there is no date selected whatsoever… I even used aria-required=“true” like in email and password but that doesnt work either.
Probem 2: How can I add a validation to that date, that only people that are 18+ can register?
Here I didnt found any previous questions to that or documentation. Please let me know if you find something or have an idea how to solve that.
Thanks for the help.