GravityForm does not focus form when returning error


I am trying to get the form with the errors focused when sending the empty form in GravityForm. I can not get it or I'm not sure if I do not know how to do it with Jquery. Help, thank you very much in advance.

Gravity Form returns a div.validation_error but I do not know how to interact with it using Jquery to do Scroll to the ID of the section, since it scrolls me with or without the div.validation_error equally.

asked by Jean Manzo 07.06.2017 в 01:34

2 answers


After an exhaustive investigation, I did it by doing the following:

$( "body, html" ).has( ".validation_error" ).animate( {
    scrollTop: $("#idSection").offset().top
} , 2000);

In case someone has the same problem here, a useful answer.

*** Add the html tag to the answer, since body does not work in all browsers. The html tag makes it work for all others based or not on IE8.

answered by 07.06.2017 в 01:51

There are two options, if you do not have re-catpcha you could enable ajax, with that everything happens in the same form and there are no page refreshments, now if you do not activate it you can do the following in the functions.php you must add the following line:

add_filter( 'gform_confirmation_anchor', '__return_true' );

With this when doing the submit, the URL will go with the hash (#) set, so the browser will scroll the page to the form.

answered by 07.06.2017 в 15:59