Dynamically Toggle Visibility of a Form Field dynamically-toggle-visibility-of-a-form-field

One really cool feature of Marketo forms is that you can dynamically hide/show form fields or fieldsets.

In this example, let’s hide the State field unless Country is selected as “United States.”
  1. Go to Marketing Activities.

  2. Select your form and click Edit Form.

  3. Select the field you want to hide/show dynamically and click the link for Visibility Rules.

  4. Find and select the field you want to build a condition around.

  5. Select the operator.

    note tip
    This is cool because you can choose fuzzy matches like “starts with.”

  6. Select the value(s) to look for, then click outside of the drop-down.

    note tip
    You can select multiple values by clicking them while the drop-down is open. For example, you can select United States and Canada.
    note note
    We previously converted Country to a pick-list field type and added all countries as values.
  7. Click Save.

And that’s it! Now when people fill out this form and select United States for Country, the State field will dynamically appear with the choices specified.

Form field behavior will work seamlessly when field values are set/updated through custom script using API functions in Forms 2.0.
Conditional fields may not work as expected if field values are modified by external scripts other than the Forms 2.0 JavaScript API.