Lanmarkian
asked on
Hidden Form Fields Showing up in Error Correction
I have a form in aspx (clients request - do not know a ton about it, but am getting by). They have a checkbox that IF checked, it shows another row of form fields.
If they DON'T check the box, that's fine. The other form fields do not show up. All fields, hidden or not, have error correction.
What I am looking to do is if the box is NOT checked, then I do NOT want the error correction to function as if those fields were visibile.
How can I get past this?
If they DON'T check the box, that's fine. The other form fields do not show up. All fields, hidden or not, have error correction.
What I am looking to do is if the box is NOT checked, then I do NOT want the error correction to function as if those fields were visibile.
How can I get past this?
The obvious thing to do would be to wrap the error correction (detection?) in an IF statement conditional on the checkbox being checked...
IF checkbox.checked THEN
...
check optional fields
...
END IF
IF checkbox.checked THEN
...
check optional fields
...
END IF
ASKER
All that does is look at 1 checkbox for an error. Not hidden form fields. The checkbox triggers other form fields to appear.
If the checkbox is not selected, then I don't want error correction checking those fields.
If the checkbox is not selected, then I don't want error correction checking those fields.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Can you help a litle further? Here is the code that is "Hidden" as well as the checkbox.
<tr id="mailme"><td colspan="10" align="center" valign="middle" style="padding-top: 5px;">
<table><tr><td><span style="font-family: 'compacta_bd_btbold'; font-size: 19px; color: white; margin-right: 8px;">PLEASE MAIL ME A COPY </span></td><td><input name="mailcopy" type="checkbox" id="mailcopy" style="display: table-cell;"/></td></tr></table></td></tr>
<tr id="physicaladdress" style="display: none;">
<td align="right" style="padding-top: 10px; padding-bottom: 10px;">ADDRESS 1</td>
<td style="padding-top: 10px; padding-bottom: 10px;"><asp:TextBox runat="server" id="Address1" CssClass="txtBoxes" style="width: 113px;" ></asp:TextBox>
<asp:RequiredFieldValidator Display="None " CssClass="errorLog" ControlToValidate="Address1" ErrorMessage="Enter your address!" text=" *" runat="server" /></td>
<td align="right" style="padding-top: 10px; padding-bottom: 10px;">ADDRESS 2</td>
<td style="padding-top: 10px; padding-bottom: 10px;"><asp:TextBox runat="server" id="Address2" CssClass="txtBoxes" style="width: 156px;"></asp:TextBox></td>
<td align="right" style="padding-top: 10px; padding-bottom: 10px;">CITY</td>
<td style="padding-top: 10px; padding-bottom: 10px;"><asp:TextBox runat="server" ID="City" CssClass="txtBoxes" style="width: 168px;"></asp:TextBox>
<asp:RequiredFieldValidator Display="None" CssClass="errorLog" ControlToValidate="PracticeName" ErrorMessage="Enter your city!" text=" *" runat="server" /></td>
<td align="right" style="padding-top: 10px; padding-bottom: 10px;">STATE</td>
<td style="padding-top: 10px; padding-bottom: 10px;"><asp:TextBox onchange="insertNow();" runat="server" ID="State" CssClass="txtBoxes" style="width: 140px;"></asp:TextBox>
<asp:RequiredFieldValidator Display="None" CssClass="errorLog" ControlToValidate="Email" ErrorMessage="Enter your state!" text=" *" runat="server" /></td>
<td align="right" style="padding-top: 10px; padding-bottom: 10px;">ZIP<br />(U.S. only)</td>
<td style="padding-top: 10px; padding-bottom: 10px;"> <asp:TextBox onchange="insertNow();" runat="server" ID="zipcode" CssClass="txtBoxes" MaxLength="10" style="width: 85px;" ></asp:TextBox>
<asp:RequiredFieldValidator Display="None" CssClass="errorLog" ControlToValidate="pnumber" ErrorMessage="Enter your zip code!" text=" *" runat="server" /></td>
</tr>
I'm not sure what you need help with, but I changed the checkbox to add runat="server":
Then, in your codebehind, wherever you're doing your error checking...
<tr id="mailme">
<td colspan="10" align="center" valign="middle" style="padding-top: 5px;">
<table>
<tr>
<td>
<span style="font-family: 'compacta_bd_btbold'; font-size: 19px; color: white; margin-right: 8px;">PLEASE MAIL ME A COPY </span>
</td>
<td>
<input name="mailcopy" type="checkbox" id="mailcopy" runat="server" style="display: table-cell;"/>
</td>
</tr>
</table>
</td>
</tr>
<tr id="physicaladdress" style="display: none;">
<td align="right" style="padding-top: 10px; padding-bottom: 10px;">ADDRESS 1</td>
<td style="padding-top: 10px; padding-bottom: 10px;">
<asp:TextBox runat="server" id="Address1" CssClass="txtBoxes" style="width: 113px;" ></asp:TextBox>
<asp:RequiredFieldValidator Display="None " CssClass="errorLog" ControlToValidate="Address1" ErrorMessage="Enter your address!" text=" *" runat="server" />
</td>
<td align="right" style="padding-top: 10px; padding-bottom: 10px;">ADDRESS 2</td>
<td style="padding-top: 10px; padding-bottom: 10px;">
<asp:TextBox runat="server" id="Address2" CssClass="txtBoxes" style="width: 156px;"></asp:TextBox>
</td>
<td align="right" style="padding-top: 10px; padding-bottom: 10px;">CITY</td>
<td style="padding-top: 10px; padding-bottom: 10px;">
<asp:TextBox runat="server" ID="City" CssClass="txtBoxes" style="width: 168px;"></asp:TextBox>
<asp:RequiredFieldValidator Display="None" CssClass="errorLog" ControlToValidate="PracticeName" ErrorMessage="Enter your city!" text=" *" runat="server" />
</td>
<td align="right" style="padding-top: 10px; padding-bottom: 10px;">STATE</td>
<td style="padding-top: 10px; padding-bottom: 10px;">
<asp:TextBox onchange="insertNow();" runat="server" ID="State" CssClass="txtBoxes" style="width: 140px;"></asp:TextBox>
<asp:RequiredFieldValidator Display="None" CssClass="errorLog" ControlToValidate="Email" ErrorMessage="Enter your state!" text=" *" runat="server" />
</td>
<td align="right" style="padding-top: 10px; padding-bottom: 10px;">ZIP<br />(U.S. only)</td>
<td style="padding-top: 10px; padding-bottom: 10px;">
<asp:TextBox onchange="insertNow();" runat="server" ID="zipcode" CssClass="txtBoxes" MaxLength="10" style="width: 85px;" ></asp:TextBox>
<asp:RequiredFieldValidator Display="None" CssClass="errorLog" ControlToValidate="pnumber" ErrorMessage="Enter your zip code!" text=" *" runat="server" />
</td>
</tr>
Then, in your codebehind, wherever you're doing your error checking...
IF mailcopy.checked THEN
...do conditional errorchecking...
END IF
...do regular errorchecking...
Open in new window
<form onsubmit="return Validate()"