这是我的表单中我的文本框的示例,带有自定义验证,我想禁用验证器:
<asp:textbox id="txtFirstName" runat="server" /></td><td>
<script language ="javascript">
function requireFirstName(source, args) {
if (document.getElementById("<%=txtFirstName.ClientID %>").value =="") {
args.IsValid = false;
}
else {
args.IsValid = true;
}
}
</script>
<asp:CustomValidator ID="RequiredValidator1" runat="server"
ErrorMessage="You must enter your first name."
ForeColor="Red" clientvalidationfunction="requireFirstName"
></asp:CustomValidator>
这是我之前的按钮:
<asp:Button ID="PreviousButton" runat="server"
Text="<-- Back to Instructions" OnClick="btnBack_Click"
class="previous" />
<script type="javascript">
document.getElementById("<%=PreviousButton.ClientID%>").disableValidation = true;
</script>
这不起作用,仍然有验证器。帮助
答案 0 :(得分:1)
<asp:Button ID="PreviousButton" runat="server" CausesValidation="false"
Text="<-- Back to Instructions" OnClick="btnBack_Click"
class="previous" EnableClientScript="false" />
答案 1 :(得分:1)
尝试将CausesValidation设置为false。
<asp:Button ID="PreviousButton" runat="server" Text="<-- Back to Instructions" OnClick="btnBack_Click" class="previous" CausesValidation="false" />