Dynamically Toggle Visibility of a Form Field

Last update: 2023-07-21
  • Topics:
  • Forms
    View more on this topic

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

NOTE

Example

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.

    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.

    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

    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.

IMPORTANT

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.

On this page