我通常在我的网络表单中使用CausesValidation=false
并且它有效,但它不适用于下面的表单。如果我输入一些数据然后单击RESET按钮,则所有必填字段(*)将消失;但是,它不会清除文本框或单选按钮中的信息。我尝试添加Javascript OnClientClick="this.form.reset();return false;"
,但仍然没有用。我检查并重新检查了我的脚本,我在网上研究但是找不到解决方案。可以有两对< section>< / section>同一< panel>中的标签造成了问题?只是好奇。我注意到我之前的表单只有一对< section>每种形式的标签;这是我第一次有两个部分。
<asp:Panel ID="submitPanel" runat="server" DefaultButton="submitBTN">
<section class="bg05 well04">
<div class="container">
<h2>Application for Enrollment</h2>
<div class="columns">
<div class="colLeft"><h4>Select Enrollment Type (select one):</h4></div>
<div class="colRight">
<asp:RadioButtonList ID="enrollType" runat="server" RepeatDirection="Horizontal" CssClass="spaced" ValidationGroup="submitApp">
<asp:ListItem Value="Full-Time">Full-Time</asp:ListItem>
<asp:ListItem Value="Part-Time">Part-Time</asp:ListItem>
</asp:RadioButtonList><div class="colAdjust"><asp:RequiredFieldValidator ID="enrollRFV" runat="server" ControlToValidate="enrollType" Font-Size="Medium" ErrorMessage=" *" ForeColor="Maroon" ValidationGroup="submitApp"></asp:RequiredFieldValidator></div>
</div>
<br /><br /><br />
<div class="colGeneral"><asp:Label ID="PriEmailLBL" runat="server" Text="<span class='format'>Primary email address:</span> "></asp:Label></div><div class="colGeneral1"><asp:TextBox ID="PriEmailTXTBOX" runat="server" Width="250px" ValidationGroup="submitApp"></asp:TextBox><asp:RequiredFieldValidator ID="PriEmailRFV" runat="server" ControlToValidate="PriEmailTXTBOX" Font-Size="Medium" ErrorMessage=" *" ForeColor="Maroon" Display="Dynamic" ValidationGroup="submitApp"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="PriEmailREV" runat="server" ErrorMessage=" Invalid email address" ControlToValidate="PriEmailTXTBOX" ValidationExpression="[a-zA-Z0-9!#$%&'*+/=?^_`{}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?" Font-Size="Medium" ForeColor="Maroon" Display="Dynamic" ValidationGroup="submitApp"></asp:RegularExpressionValidator></div>
</div>
</div>
</section>
<section class="bg02 well02">
<div class="container">
<div style="margin-top: 10px;"></div>
<h4 class="a">Member:</h4><br />
<div class="colGeneral5"><asp:Label ID="CellLBL" runat="server" Text="<span style='color:White;margin-left:55px;'>Cell #:</span> "></asp:Label><asp:TextBox ID="CellTXTBOX" runat="server" Width="150px" ValidationGroup="submitApp"></asp:TextBox><asp:RequiredFieldValidator ID="CellRFV" runat="server" ControlToValidate="CellTXTBOX" Font-Size="Medium" ErrorMessage=" *" ForeColor="Maroon" ValidationGroup="submitApp"></asp:RequiredFieldValidator></div>
<br />
<div class="colGeneral5"><asp:Label ID="SecEmailLBL" runat="server" Text="<span style='color:White;'>Secondary Email Address:</span> "></asp:Label><asp:TextBox ID="SecEmailTXTBOX" runat="server" Width="300px" ValidationGroup="submitApp"></asp:TextBox><asp:RequiredFieldValidator ID="SecEmailRFV" runat="server" ControlToValidate="SecEmailTXTBOX" Font-Size="Medium" ErrorMessage=" *" ForeColor="Maroon" Display="Dynamic" ValidationGroup="submitApp"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="SecEmailREV" runat="server" ErrorMessage=" Invalid email address" ControlToValidate="SecEmailTXTBOX" ValidationExpression="[a-zA-Z0-9!#$%&'*+/=?^_`{}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?" Font-Size="Medium" ForeColor="White" Display="Dynamic" ValidationGroup="submitApp"></asp:RegularExpressionValidator></div>
<br /><br />
<asp:Button ID="submitBTN" runat="server" Text="SUBMIT" OnClick="submitBTN_Click" ValidationGroup="submitApp" />
<asp:Button ID="resetBTN" runat="server" Text="RESET" OnClientClick="this.form.reset();return false;" CausesValidation="false" ValidationGroup="submitApp" />
<asp:Label ID="messageLBL" runat="server" Text="" Visible="false">/asp:Label>
</div>
</section>
</asp:Panel>
答案 0 :(得分:0)
更正标记并删除OnClientClick
的{{1}}后,它似乎具有所需的行为(按下'重置'时表单被清除):
resetBTN