Click here to Skip to main content
15,902,844 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please help !!
I am Using VS2008.
I am trying to apply two validation controls on a textbox. but regularexpression is not working properly.
Here is the code :


C#
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                               ControlToValidate="Finish_emailID_Txtbox" Display="Dynamic" Text=""
                               ErrorMessage="Please enter the email-ID." ValidationGroup="group5" 
                               SetFocusOnError="True"></asp:RequiredFieldValidator>
                               
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" 
                               runat="server" Text="" Display="Dynamic" ValidationGroup="group5" SetFocusOnError="True" ControlToValidate="Finish_emailID_Txtbox" 
                               ErrorMessage="Please enter the correct Email format(For Example: YourId@somedomain.com)" 
                               ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>


The problem is : On error, it is displaying the message which i have used for errormessage property(i have also taken validation summary control).



Quick help will be appreciated.
Posted
Comments
Uday P.Singh 14-Dec-11 12:55pm    
Not clear! what is your exact requirement?
palraj001 14-Dec-11 23:06pm    
its working . i didnt get any error in ur code

Try using following:
ASP.NET
 <asp:TextBox ID="tbxEmailAddress" runat="server" CssClass="text"></asp:Textbox>
 <asp:RequiredFieldValidator ID="rfvBillingEmailAddress" runat="server" ControlToValidate="tbxEmailAddress" ErrorMessage="* Required" Display="dynamic" SetFocusOnError="true" EnableClientScript="true" ValidationGroup="Vgroup">
</asp:RequiredFieldValidator><br />

<asp:RegularExpressionValidator runat="server" ID="revBillingEmailAddress" ControlToValidate="tbxEmailAddress"
EnableClientScript="true" ErrorMessage="Incorrect Email Format" SetFocusOnError="true"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="Vgroup">
</asp:RegularExpressionValidator>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="Vgroup" />
 
Share this answer
 
v3
ASP.NET
<asp:RegularExpressionValidator ID="REV_TxtBox" runat="server" ValidationGroup="group5" SetFocusOnError="True" ControlToValidate="Finish_emailID_Txtbox" 
ErrorMessage="Invalid MailId" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900