Forms - Using Conditional Logic to mark a field "Is Required"

Jason_Reber__TH
Level 2

Forms - Using Conditional Logic to mark a field "Is Required"

Hi all,

I have a form in Marketo with inputs for the user to provide their name, address, phone number, etc. I also have a "Send marketing brochure" checkbox on that form.

If this is the first time the user is submitting the form, the "Send marketing brochure" checkbox should be required.

If the user has submitted the form before (aka, if they have already been sent the marketing brochure), then the "Send marketing brochure" checkbox should be optional.

What is the best way to accomplish this?

Thanks for any help or leads (pun intended) you can provide,

Jason

8 REPLIES 8
Grégoire_Miche2
Level 10

Re: Forms - Using Conditional Logic to mark a field "Is Required"

Hi Jason,

  • You cannot make a checkbox required, because it has only 2 status : True or False, and in the case of a checkbox, empty/null = false.
  • If you want to make the field required, you will have to make it a picklist (You can set no default or False as a default)
  • There is no way to know whether the lead is filling out the form for the first or second time. But you can set the field to pre-fill, if the form is used on a Marketo landing page. If it's a picklist field, just let it required, deactivate the prefill and set it to false as a default value.

-Greg

SanfordWhiteman
Level 10 - Community Moderator

Re: Forms - Using Conditional Logic to mark a field "Is Required"

You cannot make a checkbox required, because it has only 2 status : True or False, and in the case of a checkbox, empty/null = false.

Well, you can make it required, but the outcome may not be what Jason wants.  That is, you can require it to be checked, but you can't require it to be acted upon, because there is no third choice for the user beyond checking it or refraining from checking it. As you point out, to have a tri-state field, you need something more complex like radio buttons or a select, where it is possible to both interact with the widget and set it to false.

For detecting a previously submitted form in the same browser, you can do this with an embedded form just as well.  It doesn't require a Marketo LP.  It isn't clear from Jason's description whether he expects this to work across devices (a browser being equivalent to a device for session purposes).

Grégoire_Miche2
Level 10

Re: Forms - Using Conditional Logic to mark a field "Is Required"

HI Sanford,

My assumption was that about detecting a form has been filled out across 2 sessions. But you are right, may be that was within a single session...

-Greg

SanfordWhiteman
Level 10 - Community Moderator

Re: Forms - Using Conditional Logic to mark a field "Is Required"

Yes, let's figure out what Jason is spec'ly referring to. One of those cases where slight differences in reading can change the answer from hard Yes to hard No.

Jason_Reber__TH
Level 2

Re: Forms - Using Conditional Logic to mark a field "Is Required"

Hi Greg, Sanford, thanks for your replies.

I was wanting to detect if a user had filled out the form previously, even in a different session. Is that possible out-of-the box?

I was thinking I could add a new custom field called "Has submitted Jasons form" and set the value to true on submit of the form. Then have our developer make some code changes:

The form is a two-page form, with the first page asking only for the user's email address, so before the second page is shown (with the other fields and the fields we want to require) the web code could make a call to Marketo via API to get that field's value for that individual and adjust which fields are required or not on page two.

Grégoire_Miche2
Level 10

Re: Forms - Using Conditional Logic to mark a field "Is Required"

It will take some JS coding, but I would rather use a form that's hidden at first, then when it is loaded, you would be able to look into the values and if this one is false, keep the form hidden, otherwise, change the display:none style and rerender it.

Have your developer to give a look at Forms 2.0 » Marketo Developers

-Greg

SanfordWhiteman
Level 10 - Community Moderator

Re: Forms - Using Conditional Logic to mark a field "Is Required"

I was wanting to detect if a user had filled out the form previously, even in a different session. Is that possible out-of-the box?

Out-of-the-box, no.  It requires a small amount of development. 

However, the correct method does not -- and must not -- use the Marketo API.  First of all, you cannot use the API directly from the browser.  But I can't, in professional conscience, approve of any use of the API in response to individual browser events. You will create a DoS vulnerability against your Marketo instance.

Jason_Reber__TH
Level 2

Re: Forms - Using Conditional Logic to mark a field "Is Required"

Thanks again, guys. I will have our developer review the docs, and look at the hidden form route and not go the API route!

Thanks again