View Full Version : Can a hidden div pass on form data?

09-16-2011, 09:18 PM
Say I have a form so long that i want to group sections by category and have them expandable, using css to display:none or display:block these groups. If a user selects an option or two in one of these divs, then fills in some fields, then hides the div... is it going to cause problems when they submit the form if the div is hidden?


edit: let me ask another question too--what if we add validation into the mix. What happens if a field in a hidden div does not pass validation?

09-17-2011, 01:16 AM
Answer to your first question:
It wont create any problem unless they all are within the form that will be submitted. You can and must divide large page into chunks for ease and simplification.

Answer to your second question:
Adding validation code also wont create any problem. The trick is how you will handle the failure conditions. One simplest solution is to create multiple validation methods for each group sections. So that if any hidden div does not pass the validation, you can easily identify which div you need to set visible.

Hope I have made my point clear. If you still have any confusion, please tell us.

Thanks & Regards,
Niral Soni

Old Pedant
09-17-2011, 02:02 AM
I agree with Niral. The hard part is the human interface, not the JavaScript.

What you might consider doing is validating each VISIBLE section of the <form> *before* you make it hidden and make another one visible. That way, the user isn't surprised when, on the final screen, you pop him back to the first one to fill in his name.