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

JayW
Level 2

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

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. 400 bad request.pngglobal form validation error.png

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

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

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