SOLVED

Custom page template marks form field as required

Go to solution
Jessie_Johnson
Level 2

We have a very simple custom page template, and when creating a new page and choosing this, then adding an existing form, it consistently marks the "comment" field as required, even tho this form field is not required. This custom page template is attached. And note that this form was simply cloned from an existing form which DID have the comment field required.

1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator

Yep, but it's not JS, just CSS. The <div> always exists in the DOM even for non-required fields. There's custom CSS unhiding it.

pastedImage_1.png

View solution in original post

12 REPLIES 12
SanfordWhiteman
Level 10 - Community Moderator

Jessie Johnson please return to the thread and mark my answer as Correct. As you can see, the cause is in your custom CSS stylesheet, not Marketo.

Corey_Bethel
Level 4 - Champion Alumni

The comments field only appears to be "required", but the form will submit without that field being populated. Also, the comments field is missing the "mktoRequired" class that would actually make it required. I'd say there is some custom JS that is adding the div with the "mktoAsterix" class, which is why it appears to be required.

Corey Bethel
Consultant | Etumos
SanfordWhiteman
Level 10 - Community Moderator

Yep, but it's not JS, just CSS. The <div> always exists in the DOM even for non-required fields. There's custom CSS unhiding it.

pastedImage_1.png

Jessie_Johnson
Level 2

Aha! I removed this, changed to float, and all is well again. Thank you all!

Amit_Jain
Level 8 - Community Advisor

Agree with Sanford here.

Also check on the form if you have any custom JS code which is making all the fields on the form as "Required".

Jessie_Johnson
Level 2

None

SanfordWhiteman
Level 10 - Community Moderator

Not sure why you're attributing this to the template. Please show the form setup. Ensure that both the form and the LP with the form selected have been reapproved.

Jessie_Johnson
Level 2

Only when the form is embedded in this form does the last field appear as required.

SanfordWhiteman
Level 10 - Community Moderator

We need to see the entire form. Please provide the embed code. There's nothing on that template that does anything special.

Jessie_Johnson
Level 2

Form embed is just:

<script src="//app-ab20.marketo.com/js/forms2/js/forms2.min.js"></script>

<form id="mktoForm_1417"></form>

<script>MktoForms2.loadForm("//app-ab20.marketo.com", "682-DBU-809", 1417);</script>

But form is being called through Marketo, not embed.

SanfordWhiteman
Level 10 - Community Moderator

Now a link to an approved LP showing the behavior.

Jessie_Johnson
Level 2