RegularExpressionValidator doesn't ignore case

A

A.M

Hi,

How can I set the option of RegularExpressionValidator to
RegexOptions.IgnoreCase ?

Thanks,
Alan
 
C

Chris R. Timmons

Hi,

How can I set the option of RegularExpressionValidator to
RegexOptions.IgnoreCase ?

Alan,

There is no property in the RegularExpressionValidator control that
allows regex options to be set.

If your control does both client-side and server-side validation, the
regex must use a subset of regular expression syntax that both
JScript and .Net can execute. In this case, to make a regex ignore
case it is necessary to use a character class construct like [a-zA-Z]
to match both upper and lower case characters.

If your validation is done on the server-side only, you can use the
more powerful .Net regular expression syntax. In this case, you can
place the (?i) option at the beginning of the regex to tell it to
ignore case.
 
A

Ali.M

Thanks Chris,

I actually using server side validation, so I am going to try ?i.

Alan



Chris R. Timmons said:
Hi,

How can I set the option of RegularExpressionValidator to
RegexOptions.IgnoreCase ?

Alan,

There is no property in the RegularExpressionValidator control that
allows regex options to be set.

If your control does both client-side and server-side validation, the
regex must use a subset of regular expression syntax that both
JScript and .Net can execute. In this case, to make a regex ignore
case it is necessary to use a character class construct like [a-zA-Z]
to match both upper and lower case characters.

If your validation is done on the server-side only, you can use the
more powerful .Net regular expression syntax. In this case, you can
place the (?i) option at the beginning of the regex to tell it to
ignore case.
 
S

Steven Cheng[MSFT]

Thanks for Chris's informative suggestion.

Hi Alan,

I've also tested Chris's suggestion on use the (?i) flag before your
regex when using the serverside regex validation.
Be care that the flag is (?i) rather than ?i.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
Joined
Sep 23, 2011
Messages
1
Reaction score
0
try this code , it is working fine for me

<asp:RegularExpressionValidator ID="rgEmailLogin" runat="server"
ControlToValidate="txtUserNameLogin" ErrorMessage="Enter the valid email id"

ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
ValidationGroup="vgLoginGroup">*
</asp:RegularExpressionValidator>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top