Show/Hide group of fields based on toggle

Hello all,

I can't get this code to work on my public form, but basically I'm trying to hide a group of fields that I've set to be the class 'field-to-hide' upon change of a toggle. The toggle is named 'single_applicant'. Here is my code:

fd.rendered(function() {
function hideApplicant2() {

    if (fd.field('single_applicant').value == true) {
        // Show the Due Date field
        $(fd.field('.field-to-hide').show();
    } else {
        // Hide the Due Date field
        $(fd.field('.field-to-hide').hide();
    }
}

fd.field('single_applicant').$on('change', hideApplicant2);

hideApplicant2();

});

Hello @5by5,

You need to use this code to hide/show elements by CSS class:

//hide elements
$('.field-to-hide').hide();

//show elements
$('.field-to-hide').show();

Update your code and test it.

1 Like

wonderful! Thanks, that worked great.

1 Like