Skip to main content


Scroll to top of the page issue on Gravity form submission

Scroll to top of the page issue on Gravity form submission

Scroll to top of the page issue on Gravity form submission is a common problem in WordPress. If the user completes the form and presses ‘Submit’ the page reloads to the top or scroll to the top of the page.

If the Gravity Form is placed at the bottom of the page (after the top text), usually it means that it is below the fold of the page. When a user fill the form and press ‘Submit’ button then the page reloads to the top of the page therefore (if form completed correctly) then user has to scroll down to see the confirmation message. Or more painful if a “required field” and user does not complete the field and click ‘Submit’ button when the page reloads to the top then the user may not know they have not completed fill the form correctly.

If the gravity form page scrolls to the top of the page, instead of anchoring where the form starts, this makes it seem like the form has been successfully submitted.

The user does not like to page reloads on the top if the click on the submit button from gravity form. It is a gravity form issue, need to fix it.

How to fix scroll to top of the page issue on Gravity form submission

The Gravity Form has solved this problem. We can solve it through a hook code. We have to put this hook code inside functions.php file. And whoever it is being automatically scroll, will stop.

Disabling Automatic Scrolling on top of the page on Gravity Form Submission

Use the below filter to enable the confirmation anchor functionality that will automatically scroll the page to the confirmation text or validation message upon submission the form.

add_filter( 'gform_confirmation_anchor', '__return_true' );

You can also read Gravity form documetation for more help URL https://docs.gravityforms.com/gform_confirmation_anchor/

You can also force the page to scroll to a require distance (pixel) from the top of the page. It is useful when embedding forms in a long page. The below example use all AJAX enabled forms to scroll to 100 pixels from the top of the document after being submitted.

add_filter( 'gform_confirmation_anchor', function() {
return 20;
} );

I hope this article helped you learn how to fix scroll to top of the page issue on Gravity form submission.

One thought on “Scroll to top of the page issue on Gravity form submission

Leave a Reply

Your email address will not be published. Required fields are marked *