我有一个带有 id 的文本框txtNumOfBooks
,我正在针对以下 3 个验证器进行验证:
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtNumOfBooks" Display="Dynamic" ErrorMessage="Please enter the number of books" SetFocusOnError="True" CssClass="style4" ValidationGroup="CreateVac">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtNumOfBooks" Display="Dynamic" ErrorMessage="Please enter the valid number" ValidationExpression="[0-9]\d*[0-9]" CssClass="style4" ValidationGroup="CreateVac">
</asp:RegularExpressionValidator>
<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="txtNumOfBooks"
Display="Dynamic" ErrorMessage="Number of books in a book shelf should be in range 1-100"
MaximumValue="100" MinimumValue="1" Type="Integer" CssClass="style4" ValidationGroup="CreateVac">
</asp:RangeValidator>
但是,每当我在文本框中输入字符时,两条消息:
Please enter the valid number Number of books in a book shelf should be in range 1-100
已显示。如何避免范围验证器使用正则表达式验证器消息显示其错误消息?