0

所以我有一个带有 6 个验证器的文本框。每种 2 个,因为我有两个验证组,具体取决于用户单击的按钮。我的问题是每次文本框失去焦点时都会显示两条错误消息,这看起来很奇怪。我尝试将文本框的 CausesValidation 属性设置为“false”,但它不起作用。

文本框和验证器 -

<asp:TextBox ID="collectionDtl_Qty" runat="server" CssClass="formText" 
 AutoPostBack="false" CausesValidation="false" Text="0">
</asp:TextBox>
<asp:FilteredTextBoxExtender ID="collectionDtl_Qty_Filtered" runat="server" 
 FilterMode="ValidChars" TargetControlID="collectionDtl_Qty" ValidChars="1234567890,">
</asp:FilteredTextBoxExtender>
<asp:CustomValidator ControlToValidate="collectionDtl_Qty" ID="collectionDtl_Qty_CValidator" 
 runat="server" ClientValidationFunction="coll_QtyValidator"
 Text="Quantity cannot be greater than requested quantity." ForeColor="Red" 
 ValidationGroup="formValidation" Display="Dynamic">
</asp:CustomValidator>
<asp:CustomValidator ControlToValidate="collectionDtl_Qty" ID="collectionDtl_Qty_CValidator2"
 runat="server" ClientValidationFunction="coll_QtyValidator"
 Text="Quantity cannot be greater than requested quantity." ForeColor="Red" 
 ValidationGroup="detailValidation" Display="Dynamic">
</asp:CustomValidator>
<asp:CompareValidator ControlToValidate="collectionDtl_Qty" ID="collectionDtl_Qty_Comparer" 
 runat="server" Text="Quantity must be greater than 0." ForeColor="Red" 
 ValidationGroup="formValidation" Display="Dynamic"
 ValueToCompare="0" Operator="GreaterThan" Type="Integer">
</asp:CompareValidator>
<asp:CompareValidator ControlToValidate="collectionDtl_Qty" ID="collectionDtl_Qty_Comparer2" 
 runat="server" Text="Quantity must be greater than 0." ForeColor="Red"
 ValidationGroup="detailValidation" Display="Dynamic"
 ValueToCompare="0" Operator="GreaterThan" Type="Integer">
</asp:CompareValidator>

任何帮助,将不胜感激。

4

1 回答 1

0

您好,根据您的问题。我知道您必须禁用验证器或使用基于按钮单击的验证。

  1. 对于按钮单击使用 ValidationGroup

    验证组=“保存”

  2. 如果你想在条件下禁用验证器。试试这个

    ValidatorEnable(document.getElementById('<%= rqrgvddlCategory.ClientID %>'), false);

    希望它会帮助你。

于 2013-05-07T10:51:03.593 回答