【问题标题】:How to check if .Net Validation is True before calling Click event如何在调用 Click 事件之前检查 .Net 验证是否为真
【发布时间】:2012-04-28 00:42:28
【问题描述】:

我正在使用 .Net 验证来验证我的表单。问题是当我点击提交时,它不会检查表单是否经过验证。即使字段为空白,它也会触发警报。我希望仅在验证表单后触发警报。谢谢。

<asp:ValidationSummary ID="ValidationSummary1" runat="server" CssClass="error-box" />

<asp:Label ID="empLast4Lbl" runat="server" Text="Last 4 digits of SSN#">Last 4 digits of SSN</asp:Label>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="empLast4Txt"
                    ErrorMessage="Last 4 digits of SSN is required." ForeColor="Red" CssClass="float-none">*</asp:RequiredFieldValidator>
<asp:TextBox ID="empLast4Txt" runat="server"></asp:TextBox>

<asp:Label ID="empDobLbl" runat="server" Text="Label">Date of Birth</asp:Label>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="empDobTxt"
                    ErrorMessage="Date of Birth is required." ForeColor="Red" CssClass="float-none">*</asp:RequiredFieldValidator>
<asp:TextBox ID="empDobTxt" runat="server"></asp:TextBox>

<asp:Button ID="submitEmp" runat="server" Text="Submit" Class="ap-webmethod" />

// jQuery

$(".ap-webmethod").click(function () {

                alert("Fired");

        });

【问题讨论】:

    标签: jquery validation


    【解决方案1】:

    它是通过在 ASP.NET 母版页中使用 jQuery 验证来实现的。看这个链接http://www.dotnetcurry.com/ShowArticle.aspx?ID=310

    jQuery Validation plugin in ASP.NET Web Forms

    【讨论】:

      猜你喜欢
      • 2020-02-11
      • 2021-10-18
      • 1970-01-01
      • 2012-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-07
      • 2014-07-14
      相关资源
      最近更新 更多