禁用单击按钮上的复选框验证

时间:2016-03-14 12:53:05

标签: javascript jquery

我在aspx页面中有一个带有两个按钮(button1,button2)的复选框。我试图在button2单击上验证此复选框。并且验证不应该在button1点击时触发..我知道我们可以使用组名概念。但我想要它没有这个概念...

复选框是

<asp:CheckBox ID="chkApprove" runat="server" CssClass="checkbox-inline" Text="Check here to approve" ForeColor="Red" Visible="false" />
    <asp:CustomValidator runat="server" ID="reqCheckBoxRequired" EnableClientScript="true" Display="Dynamic"
        Visible="false" ClientValidationFunction="CheckBoxRequired_ClientValidate">You must select this box to approve and proceed.</asp:CustomValidator>

两个按钮

        <div class="btn-group">
            <asp:Button ID="btnPreview" type="submit" runat="server" OnClick="btnPreview_Click" OnClientClick="fnIgnoreApprove(true)" class="btn btn-primary" Text="Preview" />
        </div>
        <div class='btn-group'>
            <asp:Button ID="btnSave" type="submit" runat="server" OnClick="btnSave_Click" OnClientClick="fnIgnoreApprove(false)" class="btn btn-success" Text="Save" Visible="false" />
        </div>

脚本代码是

<script>

    function CheckBoxRequired_ClientValidate(sender, e) {
        if (!document.getElementById("MainContent_reqCheckBoxRequired").disabled) {
            e.IsValid = document.getElementById("<%=chkApprove.ClientID %>").checked;
    }
};
 function fnIgnoreApprove(toDisable) {
        debugger
        var name = document.getElementById("<%= reqCheckBoxRequired.ClientID %>");
        ValidatorEnable(name, toDisable);
    };

这里reqCheckBoxRequired是customvalidator id .. 我收到一个未定义名称的错误...

0 个答案:

没有答案