我有多个RequiredFieldValidator,例如:
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtbox1"
Display="Dynamic" ErrorMessage="Required Field" SetFocusOnError="True"
ValidationGroup="validator1" CssClass="validator" />
链接到此按钮:
<asp:LinkButton runat="server" ID="btnNext1" Text="Next Page" CssClass="btn" ValidationGroup="validator1" />
连同一些javascript:
<script type="text/javascript">
$(function() {
function nextPage1() {
$( "#divFirstPage" ).hide("fade");
$( "#divSecondPage" ).show("fade");
$( "#<%=btnNext1.ClientID%>" ).hide();
$( "#<%=btnNext2.ClientID%>" ).show();
$( "#<%=btnPrevious1.ClientID%>" ).show();
};
$( "#<%=btnNext1.ClientID%>" ).click(function() {
nextPage1();
return false;
});
$( "#divSecondPage" ).hide();
$( "#divThirdPage" ).hide();
$( "#<%=btnNext2.ClientID%>" ).hide();
$( "#<%=btnPrevious1.ClientID%>" ).hide();
$( "#<%=btnPrevious2.ClientID%>" ).hide();
});
</script>
但是 javascript 在验证之前执行,所以 id 需要在 javascript之前执行验证