思路:1、在前台給驗證控件註冊一個屬性 2、在JS中通過這個屬性獲取到驗證控件,實現禁用。
如下:1、<asp:CompareValidator ValidationGroup="AddRoom" ID="cvDivActinRom" runat="server"
isnotshow="true" ErrorMessage="測試JI是否能禁用驗證控件" ControlToCompare="txtEnd"
ControlToValidate="txtDStart" Display="Dynamic" ForeColor="Red" Operator="GreaterThan"
SetFocusOnError="false"></asp:CompareValidator>
2、 $("[isnotshow]").each(function (index, element) {
ValidatorEnable(element, false);
});