Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can a hidden div pass on form data?

    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?

    Thanks!

    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?

  • #2
    Regular Coder
    Join Date
    Mar 2008
    Location
    London
    Posts
    152
    Thanks
    4
    Thanked 42 Times in 42 Posts
    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

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,232
    Thanks
    80
    Thanked 4,456 Times in 4,421 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •