这是我的表单中具有自定义验证的文本框的示例,我想禁用验证器:
<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>
这不会起作用,但仍然有验证器..help
最佳答案
尝试设置CausesValidation为假。
<asp:Button ID="PreviousButton" runat="server" Text="<-- Back to Instructions" OnClick="btnBack_Click" class="previous" CausesValidation="false" />
关于c# - 上一个按钮显示验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6474060/