Page 1 of 1

Conditional Fields clearing On Submit

Posted: 24 Jun 2015
by Jdubs
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!

Re: Conditional Fields clearing On Submit

Posted: 25 Jun 2015
by rostislav
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:

Code: Select all

function hideUnhideFields() {
 // your logic here
}

// When a field has been changed
fd.field('Field1').change(function() { hideUnhideFields() })

// When a form is loaded:
hideUnhideFields();