Jump to content

Email Doman Requirement


rnewcomer

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.

Thoughts?

Link to comment
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.!#$%&'*+\/=?^_`{|}~-]+@mycorporatedomain\.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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...