Forms: Field visibility rules on a hidden field

Natali_Talevski
Level 4

Forms: Field visibility rules on a hidden field

Hi guys,

Is there a way to stop a hidden field on a form from prepopulating when a certain value is selected? I'm essentially looking to replicate the way the visibility rules will hide a field, for example, a form has Country and State; if Canada is selected, hide the State field.

Can you do something similar with a hidden field? The hidden field I'm trying to block prepopulates with a timestamp - I want this timestamp not to pass through if a certain value is selected in the form.

Thanks

Natali

Tags (1)
3 REPLIES 3
Grégoire_Miche2
Level 10

Re: Forms: Field visibility rules on a hidden field

Hi Natali,

You will have to use some Javascript to do this.

-Greg

SanfordWhiteman
Level 10 - Community Moderator

Re: Forms: Field visibility rules on a hidden field

MktoForms2.whenReady(function(form){

  form.onSubmit(function(form){

    if ( form.getValues()['YourVisibleFieldName'] == 'YourCertainValue' ) {

      form.setValues({

        'YourHiddenFieldName' :null

      });

    }

  });

});

Natali_Talevski
Level 4

Re: Forms: Field visibility rules on a hidden field

Thanks so much. I'll give it a go