RegEx Validation Control Bug??

M

Mike

I'm trying to have a form where a user has to enter a valid email address, and
I'm trying to use the RegEx Validation control to do that. The problem is that
when a user submits the form with a blank line, it is ACCEPTED even though it
does not pass the pattern match in the expression.

Another problem is that if there are leading spaces or trailing in a valid email
address, the expression fails.

Case 1:(blank) : PASSES (it shouldn't)
Case 2: (e-mail address removed) : FAILS (leading spaces)
Case 3:[email protected] : FAILS (trailing spaces)


<form id="Form1" method="post" runat="server">
Enter your Email address:
<asp:TextBox id="txtEmail" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator id="valRegExEmail" runat="server"
ErrorMessage="Enter a valid email address"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate="txtEmail">*</asp:RegularExpressionValidator>
<br>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
<br>
<asp:ValidationSummary id="ValidationSummary1"
runat="server"></asp:ValidationSummary>
</form>
 
N

NoOne

I think in the documentation it says all validators accept empty string as
valid except the required validator.
 

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,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top