FreeTextBox的RequiredFieldValidator和RegularExpressionValidator在2个位置显示错误消息

时间:2013-11-15 03:50:06

标签: c# asp.net

在我的aspx页面中:

<table cellpadding="2" cellspacing="2" align="center">
<tr>
  <asp:ValidationSummary ID="Alert" runat="server" CssClass="failureNotification" HeaderText=""/>                                  
</tr>

 <tr>
   <FTB:FreeTextBox id="FTB" runat="server"/>
  <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="FTB" CssClass="failureNotification" ErrorMessage="Content cannot be empty." ToolTip="Content cannot be empty." ></asp:RequiredFieldValidator> 
  <asp:RegularExpressionValidator ID="rev" runat="server" ControlToValidate="FTB" ErrorMessage="Text with only spaces is not allowed." ToolTip="Text with only spaces is not allowed "  ValidationExpression="[^\s]+" CssClass="failureNotification"/>                      
 </tr>
</table>

我正在为FreeTextBox RequiredFieldValidator使用1 RegularExpressionValidator和1 FTB

当我将FreeTextBox设为空时,RequiredFieldValidator的错误消息显示在2个位置:enter image description here

当我在FreeTextbox中仅按空格时,它与RegularExpressionValidator的错误消息相同。

Note: RequiredFieldValidator的2个职位和RegularExpressionValidator的2个职位。两者都不是2个位置。

帮助!!!我只想将错误信息显示在1个位置:在表格顶部!!!

0 个答案:

没有答案