Using Regular Expressions to restrict email domain

10 years 8 months ago #125392 by ckayfish
After spending some time looking for a joomla or CB plugin to allow me to restrict email domain, and finding nothing that supported this feature for CB, the light went on. I can use a Regular Expression to validate my email field.

I used PERL a long time ago, but never was a regex expert so it took me a little bit to figure out exactly how to define my expression.

To limit registration for your site to a specific email domain (@my.domain.com or example) edit your primary email field CB Field Manager, set Field Entry Validation to PERL Regular Expression and use the following code

[code:1]/^.*@my\.domain\.com$/[/code:1]

below would allow ony .edu addresses to register

[code:1]/^.*\.edu$/[/code:1]

I found a post from Krilion that provided this URL which helped

Tips for understanding and solving your issue - Props to Krileon for creating this.
My Opensource CB Plugins: Mutual Connections and MYCB Cookie available here

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.396 seconds

Facebook Twitter LinkedIn