在文本框上应用两个验证控件 [英] apply two validation controls on a textbox
本文介绍了在文本框上应用两个验证控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮忙!!
我正在使用VS2008.
我正在尝试在文本框上应用两个验证控件.但正则表达式无法正常工作.
这是代码:
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 :
<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>
问题是:出现错误时,它会显示我已用于errormessage属性的消息(我也已采用了验证摘要控件).
我们将不胜感激.
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.
推荐答案
尝试使用以下内容:
Try using following:
<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" />
<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>
这篇关于在文本框上应用两个验证控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文