Jump to content
Sign in to follow this  

Email Doman Requirement

Recommended Posts

Good morning everyone.  Hope the new year finds everyone well.

Have a quick question, that I hope has a quick "fix".

Is there a way to set the domain for an an email address when a "customer" registers?  Meaning... I have a "captive" customer set.  We only sell within our group, but they must register to place orders and such.  We have a number of people that do not follow directions well and are registering with different domains (gmail, icloud, and yes, even aol.com).  I would like to have it set that you can only register with my company domain.  If that domain is not entered, it will not allow the customer to register.

Email address is a required field, I would further like to make the domain a requirement.


Share this post

Link to post
Share on other sites

What we will try is to make a slight change to Foundation's Validator javascript function (if you are using Foundation).

In /skins/foundation/js/3.cubecart.validate.js, find near line 19:

    $.validator.addMethod("phone", function(phone, element) {
        phone = phone.replace(/\s+/g, "");
        return this.optional(element) || phone.match(/^[0-9-+()]+$/);
    }, $('#validate_phone').text());

On a new blank line above that, add:

$.validator.methods.email = function( value, element ) {
  return this.optional( element ) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-][email protected]\.com$/.test( value );

Change mycorporatedomain\.com to whatever you need it to be - keeping the backslash in front of the period. This code overrules the default pattern used to validate email addresses. This validation happens everywhere an email address is entered.

Next, we can change the error message that shows when the address entered does not conform to the pattern. We will update the language, since otherwise we would need to edit each template that has an email field.

In admin, Languages, click the Edit icon of the language(s) you use. Choose the Common group. Scroll to 'error_email_invalid' and change the phrase to:
Please enter a valid corporate email address.

If you wish, you can also change the 'email' phrase to:
Corporate Email

Same with 'email_example', using the corporate email address.

Finally, have CubeCart clear its internal cache and have your browser force reload the page resources.

Edited by bsmither

Share this post

Link to post
Share on other sites

That's perfect.  Exactly what I needed.

Thank you

Edited by rnewcomer

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...