Emails restricted to domain, custom validation

Solved
Highlighted
New Member
2 0 1

Hello,

I am looking for a way to restrict email addresses that can be used for customer registration to a specific domain.
I can just add the "pattern" attribute to the input field, but one might just open the dev-tools, delete the pattern and use whatever email he/she wants for registration again.

Is there a way to restrict the emails to a specific domain somewhere in the settings? If not - how would I implement a custom validation for this?

Best,
Peter

0 Likes
Highlighted
Shopify Expert
55 10 21

This is an accepted solution.

Hi @Dynatrace!

There aren't any settings in the Shopify admin that allow you to restrict a customer's email address to use a specific domain (or list of domains), so you'll either need to add some custom code to your store's theme, or you'll need to use an app that offers this type of functionality. I am not a developer myself so I'm afraid I cannot provide much assistance as far as custom code is concerned, but it may be possible to do what you are looking for with some JavaScript (since as you mentioned the pattern attribute in HTML is pretty easy to get around for someone who is savvy enough).

If you are willing to consider an app to achieve your goal, then I suggest looking at Customer Fields. The app's form builder has some powerful built-in validation rules which can be applied to virtually any field, including the email field. You can easily add a validation rule to the email address field on the store's registration form to force the user to match a regex, or use a specific domain for their email address. Here's a screenshot that shows an example of how to set this up in the Customer Fields app:

Email domain validation in CF.png

Hopefully this helps, Peter!

Kyle W | Helium Dev, LLC
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
Helium builds user friendly apps with top-rated US-based support
Our apps: Customer Fields & Meteor Mega Menus
Highlighted
New Member
2 0 1

definitely helps, yes. thank you! I'll take a look at the app and else will try with some scripting.