SOLVED

Controling "required" fields from landing page?

Go to solution
Anonymous
Not applicable

Controling "required" fields from landing page?

I'm curious if there's a way to control the required status of form fields from a landing page? I added javascript to the page, hoping to control it by simply removing the 'mktoRequired' classes ( and hiding the fields with css ), and was successful. But it didn't seem to work. The form would not submit, staying on the page, regardless of the post-submit redirect instructions. Maybe the .js approach is too unpredictable.

But, this leaves me asking if it's possible to control form field required statuses from the landing page it's on? If so, how? My reasoning is, if this were possible, I could use one form for several pages (where it's appropriate to do so) and simply modify via the landing page editor with css and js to show/hide and require/un-require fields.

Thoughts?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Controling "required" fields from landing page?

It's not that it's unpredictable, it's that the HTML classes are not the only way that the required state is stored -- there's a whole JS object behind it.

If you need to have flexible validation (not a bad idea), use the Forms2 onValidate event instead of setting fields as required in the Form Editor.  That lets you throw your own custom errors (using the Marketo error popup).

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: Controling "required" fields from landing page?

It's not that it's unpredictable, it's that the HTML classes are not the only way that the required state is stored -- there's a whole JS object behind it.

If you need to have flexible validation (not a bad idea), use the Forms2 onValidate event instead of setting fields as required in the Form Editor.  That lets you throw your own custom errors (using the Marketo error popup).

Anonymous
Not applicable

Re: Controling "required" fields from landing page?

ah.. ok, something to look into. But... if someone were to turn off javascript, there wouldn't be any backup validation, server-side or anything?

SanfordWhiteman
Level 10 - Community Moderator

Re: Controling "required" fields from landing page?

All client-side form validation requires JavaScript. That's the case whether you use Marketo's built-in validation or custom validation.

Anonymous
Not applicable

Re: Controling "required" fields from landing page?

Sorry, I might not have asked that clearly. I know Client-side validation requires javascript, but...

Does Marketo also have server-side validation when a field is set to 'required' the traditional way - via the form editor in their system.

SanfordWhiteman
Level 10 - Community Moderator

Re: Controling "required" fields from landing page?

Marketo will accept the form post either way.