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 1blank) : 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>
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 1blank) : 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>