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?
Solved! Go to Solution.
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).
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).
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?
All client-side form validation requires JavaScript. That's the case whether you use Marketo's built-in validation or custom validation.
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.
Marketo will accept the form post either way.