We deal with many french clients and this is a problem on our sign up forms.
How can I tell the control to allow for french characters?
Ultimately, the regex is the default one supplied by Microsoft:
\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
We deal with many french clients and this is a problem on our sign up forms.
How can I tell the control to allow for french characters?
Ultimately, the regex is the default one supplied by Microsoft:
\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
Well basically the result of the regex should not be different whether there are accents or not. (See Regex accent insensitive? for reference)
But besides - i was not aware, that accents are valid within emails.
Even if I can't make the regex provided by Microsoft work, if \w still doesn't match special characters as èéà you can replace any \w
instance with [\wèéà]
to make this regex accept any word literal and also any of the special chars you provide (maybe omit those special characters in the domain part, I think you'll never find some@test.còm)
Maybe it is not in the answer scope, but would you take some time to look at the answers to this question to get some ideas about email validation?
try this:
ValidationExpression="\w*[\éèà]+([-+.']\w+)*@\w*[\éèà]+([-.]\w+)*\.\w+([-.]\w+)*" />
Where [\éèà] are your special characters 'list'. You can also add /i ( [\éèà]/i ) to ignore case sensitive.
But I recommand to validate the email in the back-end:
public bool IsValidEmail(string email)
{
bool isValidEmail = false;
try
{
var validEmail = new MailAddress(email);
isValidEmail = true;
{
catch (FormatException ex)
{
// The email has not a good format
}
}
Try many ways above for the French email and all of those does not work for me and I find a solution is works for me.
ValidationExpression="[À-ÿ\w]+([-+.'][À-ÿ\w]+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"