如何使用 jquery 更新 ValdationSummary

How update ValdationSummary using jquery

这是 aspx:

<asp:TextBox ID="txt_name" runat="server" CssClass="input_class" ValidationGroup="A"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfv_txt_name" runat="server" ErrorMessage="Please enter your name." ValidationGroup="A" Text="The field is required." Display="Dynamic" ControlToValidate="txt_name" CssClass="rfv_class" ToolTip="The field is required."></asp:RequiredFieldValidator>
<asp:Button ID="btn_contact" runat="server" Text="Send Message" ValidationGroup="A" />
<asp:ValidationSummary ID="Validation_Summary_1" runat="server" ValidationGroup="A"/>

txt_name为空时点击btn_contactValidation_Summary_1's message = Please enter your name.+RequiredFieldValidator's text = The field is required.出现。

现在,当我点击 txt_name 并输入内容并点击此文本框外时,RequiredFieldValidator's text = The field is required. 消失了。

但是 Validation_Summary_1's message = Please enter your name. 仍然存在,直到我单击 btn_contact

如何通过单击 txt_name 之外的内容来更新 Validation_Summary_1

使用下面的代码进行客户端验证,同时更新 JavaScript 中的 ValidationSummary:

Page_ClientValidate("Your_Validation_Group");

Page_ClientValidate - Use This Method From Javascript for ASP.Net Client Side Validation

使用下面的代码,您可以检查页面是否有效:

Page_IsValid