Pardot Field Dependency Solution

Lets face it, Pardot does a lot of things well, and when it comes to add a field dependent on another, they made it really easy.  The problem is when you have say 100 values to check for dependencies.  Because Pardot doesn’t allow a “value is NOT”, you end up building those 100 dependencies one by one, which is not only annoying, but slows down the form to a point where it it becomes useless.

I know what you are thinking, “Use a Form Handler!”.  Yes, that would solve the problem.  If you have a developer in house, he can build the form, add the dependencies in JavaScript and  viola!  But what if you have 50 forms to re-create, or no developer at hand, etc?

Here a simple solution to avoid, replacing your forms with form handlers and still be able to have field dependencies using a “value is not” approach.  In the code below, I am only showing Privacy Policy checkbox, if the country is NOT the United States. Just add this to the form section of your Layout Template.  I have highlighted the areas you would have to edit in order for it to work for you.

<script>
const stateField = document.getElementById(‘492541_74763pi_492541_74763‘);
const checkboxField = document.getElementsByClassName(‘Privacy_Policy_Opt_In‘)[0];
stateField.addEventListener(‘change’, function () {
    //console.log(‘function called: ‘+ stateField.value);
    if (stateField.value != ‘830227′) {
        checkboxField.style.display = ‘block’;
    }
    else {
        checkboxField.style.display = ‘none’;
    }
 });
</script>
<style type=”text/css”>
.Privacy_Policy_Opt_In {
    display:none;
 }
</style>