下面的代碼不會隱藏「info」DIV,並在Page_ClientValidate被調用時將「isValid」設置爲true來顯示「questions」DIV。如果我將isValid設置爲true或false,則按預期工作。
Page_ClientValidate爲什麼阻止隱藏/顯示行爲發生?Div在調用Page_ClientValidate後不會隱藏
function hide() {
var isValid = Page_ClientValidate('validInfo');
if (isValid) {
if (!$('[id$=chkConfirm]').is(':checked'))
{ alert("Please confirm and agree with conditions"); }
else {
$('#info').hide();
$('#questions').show();
}
}
}
下面是HTML - 我把它縮短到主要部件和只有一些txtBoxes和radioLists在DIVS:
<div id="info">
<asp:TextBox ID="tBoxTradingName" runat="server" Width="200"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="tBoxTradingName"
ValidationGroup="validInfo">Required</asp:RequiredFieldValidator>
<asp:CheckBox ID="chkConfirm" Text=" I confirm that the information provided above is accurate."
runat="server" />
<asp:Button ID="btnNext" Text="Next >>" runat="server" OnClientClick="hide()" Width="100"
CausesValidation="true" ValidationGroup="validInfo" />
</div>
<div id="questions" style="display:none;">
<div class="label">
Do you trade as a
</div>
<asp:RadioButtonList ID="rBtnTradeAs" runat="server">
<asp:ListItem>Sole Proprietor</asp:ListItem>
<asp:ListItem>Company</asp:ListItem>
<asp:ListItem>Closed Corporation</asp:ListItem>
<asp:ListItem>Trust</asp:ListItem>
<asp:ListItem>Other (please specify)</asp:ListItem>
</asp:RadioButtonList>
<asp:TextBox ID="txtBoxTradeAs" runat="server" Width="200"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator30" runat="server" ControlToValidate="rBtnTradeAs"
ErrorMessage="Required">
</asp:RequiredFieldValidator>
</div>
你調試? – 2012-04-12 14:02:34
請添加HTML代碼以及... – 2012-04-12 14:05:40
@TimSchmelter是的,它進入了其他部分,但DIV不會改變 - 頁面只是滾動到頂部 – 2012-04-12 14:11:20