简体   繁体   English

如何使用 jquery 更新 ValdationSummary

[英]How update ValdationSummary using jquery

Here is aspx :这是 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"/>

When txt_name is empty & click on btn_contact , Validation_Summary_1's message = Please enter your name.txt_name为空并单击btn_contactValidation_Summary_1's message = Please enter your name. + RequiredFieldValidator's text = The field is required. + RequiredFieldValidator's text = The field is required. show up.出现。

Now when i click on txt_name & type something & click outside of this textbox RequiredFieldValidator's text = The field is required.现在,当我单击txt_name并键入一些内容并在txt_name本框之外单击RequiredFieldValidator's text = The field is required. is vanished.消失了。

But Validation_Summary_1's message = Please enter your name.但是Validation_Summary_1's message = Please enter your name. is still there until i click on btn_contact .仍然存在,直到我点击btn_contact

How can i update Validation_Summary_1 by click on outside of txt_name ?我如何通过单击txt_name外部来更新Validation_Summary_1

Use the code below for client side validation & also update ValidationSummary in JavaScript :使用下面的代码进行客户端验证并在 JavaScript 中更新 ValidationSummary :

Page_ClientValidate("Your_Validation_Group");

Page_ClientValidate - Use This Method From Javascript for ASP.Net Client Side Validation Page_ClientValidate - 使用来自 Javascript 的此方法进行 ASP.Net 客户端验证

With the code below you can check if page is valid or not :使用下面的代码,您可以检查页面是否有效:

Page_IsValid

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM