views:

138

answers:

3

I have a e-mail address validator but I need to add special characters as valid for example ü, ç... Because users in Turkey (or anywhere else) can have a web site url like: hasangürsoy.com My code is below:

<asp:TextBox ID="tEMail" runat="server" />
<asp:RequiredFieldValidator ID="rfvEMail" runat="server"
    ControlToValidate="tEMail" ErrorMessage="* required" />
<asp:RegularExpressionValidator ID="revEMail" runat="server"
    ControlToValidate="tEMail" ErrorMessage="* invalid"
    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" />
+1  A: 

\w+([ü,ç,other characters here][-+.']\w+)*@\w+([ü,ç,,other characters here][-.]\w+)*\.\w+([ü,ç,,other characters here][-.]\w+)*
lakhlaniprashant.blogspot.com
This does not validate my man, sorry
HasanGursoy
+1  A: 

You can use the special format "\u00fc" to specify the hex value of the char. Look at the table here http://www.ascii.cl/htmlcodes.htm

Jacee
Could you please explain how to use this in the expression?
HasanGursoy
Like any other backslash operator like \. (dot character)[\.\u00fc\u00e7]+
Jacee
A: 

Okay I did it:

<asp:RegularExpressionValidator ID="revEMail" runat="server"
    ControlToValidate="tEMail" ErrorMessage="* invalid" Display="Dynamic"
    ValidationExpression="\w*[\wçığöşü]+([-+.']\w+)*@\w*[\wçığöşü]+([-.]\w+)*\.\w+([-.]\w+)*" />
HasanGursoy
Be careful, if you use this e-mail validation expression the mail address can't pass validation when you try to use it for example ReplyTo address.
HasanGursoy