How can I have the form fields highlight in red (for errors from validation) ONLY after the user hits on the submit button? | Community
Skip to main content
December 17, 2015
Solved

How can I have the form fields highlight in red (for errors from validation) ONLY after the user hits on the submit button?

  • December 17, 2015
  • 2 replies
  • 1735 views

Currently, the form fields' are being highlighted in red from the mktoInvalid class that's being added, even before the user hits on "Submit", as soon as the field has been clicked on. Is there any way to have this validation check run only after the user hits on Submit? Thanks!

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

Yes, Min, you can do this.

Using CSS, hide the .mktoError and related styles by default.  Then, in a custom onValidate function, restore the visibility (an easy way is to add a class to the <FORM> that overrides the previous styles).  The onValidate does not run when entering or leaving the field, but only (by default) when the submit button is pressed.

2 replies

Frank_Breen2
Level 8
December 18, 2015

Marketo has validation rules turned on for some fields, for example Email should be a valid Email Address, clicking on and off the field will activate the error message, other field types have the same sort of features, see here - Custom Field Type Glossary - Marketo Docs - Product Docs

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
December 18, 2015

Yes, Min, you can do this.

Using CSS, hide the .mktoError and related styles by default.  Then, in a custom onValidate function, restore the visibility (an easy way is to add a class to the <FORM> that overrides the previous styles).  The onValidate does not run when entering or leaving the field, but only (by default) when the submit button is pressed.