本文介绍了在jquery中可见的必需字段验证器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am trying to visible required field validator in jquery.







<asp:DropDownList ID="ddlPaymentMode" runat="server" CssClass="form-control input-sm">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvPaymentMode" runat="server" ControlToValidate="ddlPaymentMode" ValidationGroup="frmBankSave"

 ErrorMessage="Please select Payment Mode" SetFocusOnError="True" CssClass="fa text-red"

 Display="Dynamic" InitialValue="0"></asp:RequiredFieldValidator>
<asp:DropDownList ID="ddlBankName" runat="server" CssClass="form-control input-sm"></asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvBankName" runat="server" ControlToValidate="ddlBankName" ValidationGroup="frmBankSave"

ErrorMessage="Bank required" SetFocusOnError="True" CssClass="fa text-red"

 Display="Dynamic" InitialValue="0"></asp:RequiredFieldValidator>









我尝试过:



$('#<%= ddlPaymentMode.ClientID%>')。on('change',function(){

if($('#<%= ddlPaymentMode.ClientID%> :selected')。val()==C){

ValidatorEnable($ get('<%= rfvBankName.ClientID%>'),False);

}

其他

{

ValidatorEnable($ get('<%= rfvBankName.ClientID%>'),True );

//显示错误信息。

//但我想点击按钮上的错误信息

}

}



What I have tried:

$('#<%=ddlPaymentMode.ClientID %>').on('change', function () {
if ($('#<%=ddlPaymentMode.ClientID %> :selected').val() =="C") {
ValidatorEnable($get('<%=rfvBankName.ClientID %>'), False);
}
else
{
ValidatorEnable($get('<%=rfvBankName.ClientID %>'), True);
//It shows an Error Message.
//But I want error message on button click
}
}

推荐答案




这篇关于在jquery中可见的必需字段验证器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 22:05