How to change email validation rules

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 лет назад
Hi,

I need to allow specials characters in email adresses (like quote) but I don't find where I have to change.

I tried to modify regular expression but I still have "email is not valid" when saving.

Somebody knows where is check the email value ?

Thanks
14 лет назад
I'm assuming you're talking about the registration form.  It is located in Modules/CustomerRegister.ascx.  The EmailRegularExpression is set to default as:

[\w\.-]+(\+[\w-]*)?@([\w-]+\.)+[\w-]+

If you want to add any literal symbols, add them inside the square brackets [].

Example:

[\w\.-"]+(\+[\w-"]*)?@([\w-]+\.)+[\w-]+

I added the quotes for you.  Try this example regular expression to see if it works.  I didn't add the quotes to the domain name because I can't see why a domain name would have a quote.
14 лет назад
Thanks for your help but I still have the message "Could not create new customer: InvalidEmail ".

I also tried single quote, twice quote and other characters, I always have the message.

Finally I tried the simple regular expression ".+@.+\..+" in customerregister.ascs and customerinfos.ascx and I still have the problem.

I don't find where is checked this value.

Regards,
14 лет назад
This issue is now solved.

The problem was that 3 regular expressions are used to valid email.

The first in EmailTextBox.ascx with the expression : ".+@.+\..+"

The second in CustomerInfo.ascx and CustomerRegister.ascx (3 times) with the expression : "[\w\.-]+(\+[\w-]*)?@([\w-]+\.)+[\w-]+"

The third in the CommonHelper class in NopSolutions.NopCommerce.Common.Utils namespace with the following expression : "^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"

I decided to replace all them (except EmailTextBox.ascx) with the validation expression shipped in standard with Visual Studio 2008 to check internet addresses : "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

Regards
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.