Conditional Fields clearing On Submit

rss

Posted by Jdubs - Jun 24 ’15 at 11:17

I have conditionally-revealed fields based on user selection.

 

Everything works great, BUT ... if a user Submits the form with a Required field blank, it gives the user an error (as intended) but then HIDES all the conditionally-revealed fields (while keeping the field values the same ... so the fields should still be revealed).

 

Any way to fix this?  It's a lot of code ... I don't want to have to Copy and Paste all my code in the on.submit handler just to keep my fields available.

 

Thanks!

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 6 months 26 days
    #1 by rostislav Jun 25 ’15 at 05:19

    You can move your code that hides/unhides fields into a separate function. Call this function whenever it is required, i.e. in your handlers as well as when the form is loaded:

    function hideUnhideFields() {
     // your logic here
    }
    
    // When a field has been changed
    fd.field('Field1').change(function() { hideUnhideFields() })
    
    // When a form is loaded:
    hideUnhideFields();
    
Displaying 1 to 1 of 1 messages