Is there a way to (scroll up and) set focus on the email field when Global Form Validation Error kicks in | Community
Skip to main content
Level 2
May 21, 2024
Question

Is there a way to (scroll up and) set focus on the email field when Global Form Validation Error kicks in

  • May 21, 2024
  • 1 reply
  • 899 views

Marketo form field validation on required fields, particular field value formats (i.e. email & phone) are pretty straight forward and we have a script working with onValidation callback to set focus on the first error from the top of the form.

However, the Global Form Validation is done at the server side and the behaviour isn't the same. In a long form, we get the error message but the form fails to scroll back up and set focus on the email address error. 
I noticed @sanfordwhiteman 's trick to localise the error message.
Can we adapt that method to set focus on the email address field error?

I also noticed that the way the form is throwing the error is as a 400 Bad request. Does that prevent any js running from that point forward? Is that why the form doesn't scroll back up to the error as other validation checks. 

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
May 24, 2024

Yes, you could leverage the same interception logic to focus the Email Address input.