How to show the number of "This field is required" in Marketo forms | Community
Skip to main content
Level 1
February 3, 2022
Question

How to show the number of "This field is required" in Marketo forms

  • February 3, 2022
  • 1 reply
  • 1493 views

As it works today, if you miss to fill out a required field you will see “This field is required”. If you miss to fill in several fields you will still see “This field is required” one field at the time. 

 

Would it be possible to show the number of fields that is required as a complement to how it is today? For example if I have not filled in any form and press Download/ Submit button, it should appear a text that says “7 fields are required”.

 

Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SanfordWhiteman
Level 10
February 3, 2022

“7 fields are required” I‘d think.

 

You can get the number of (natively) invalid fields and do whatever you want with it:

MktoForms2.whenReady(function(mktoForm){ let formEl = mktoForm.getFormElem()[0]; mktoForm.onValidate(function(nativeValid){ if(!nativeValid){ let numInvalids = formEl.querySelectorAll(".mktoRequired.mktoInvalid").length; // do something with numInvalids } }); });
Jo_Pitts1
Community Advisor
Community Advisor
February 3, 2022

With some special case coding for "1 field is required" (no s on fields and is not are)

Cheers

Jo