• Home
  • Pricing
  • Free Resources
  • About
  • Docs
  • Support
  • Account

Gravity Wiz

Magically enhanced tutorials, snippets and plugins for Gravity Forms!

  • Gravity Perks
    • Gravity Perks
    • Pricing
  • Blog
    • Free Resources
    • About
  • Support
    • Docs
    • Support
    • Account

Fix Gravity Form Tabindex Conflicts

Avoid the annoying issue where tabbing from a field in one form tabs you to a field in another form. This is caused by conflicting tab indexes.

Last updated February 6, 2023 | Written by David Smith 49 Comments

  • January 2nd, 2014: Updated to fix tabindex issues with forms added via the Gravity Forms widget.

Stop! This method is no longer recommended.

For accessibility reasons, adjusting the tabindex for Gravity Forms should be avoided. Giving the form priority over other interactive content is detrimental to users that rely on keyboard navigation.

  • More info
Gravity Forms 2.3 removes the tabindex property by default. Unless a custom tabindex is specified, this fix will no longer be needed.

This is most common when loading a Gravity Form on a page which is loading a non-GF form (like the WordPress comment form). You’re typing away on your Gravity Form and tab to the next field. Awesome. Except the next field is a completely different form. This snippet sets the starting index of your Gravity Form inputs ridiculously high so such conflicts never happen again.

{Gist removed. This article has been deprecated.}

How do I install this snippet?

Easy peasy. Just copy and paste the code above into your theme's functions.php file.

How to I use this functionality?

This snippet is plug-n-play. No changes needed (unless you’re still seeing tabindex conflicts which is highly unlikely). If you are, just update the 1000 in the snippet to a higher number until the conflict disappears.

Filed Under: Deprecated

Comments

  1. Guido Pettinari says

    March 29, 2016 at 7:41 am

    Hi!

    Nice snippet of code, thanks!

    If there are n>1 Gravity Forms on the same page, it might be useful to assign a different tabindex value to each of them. I achieved this by adding a line to the if block:

    function gform_tabindexer( $tab_index, $form = false ) { $starting_index = 1000; // if you need a higher tabindex, update this number if( $form ) { add_filter( ‘gform_tabindex_’ . $form[‘id’], ‘gform_tabindexer’ ); $starting_index *= min( $form[‘id’], 10 ); } return GFCommon::$tab_index >= $starting_index ? GFCommon::$tab_index : $starting_index; }

    [updated snippet can be found on gist: https://gist.github.com/31b7e1a2d874dc41d4a6%5D

    Cheers, Guido

    Reply
    • Guido Pettinari says

      March 29, 2016 at 7:43 am

      Sorry David, the comment parser has mangled my code & link. This is the correct link for the snippet:

      https://gist.github.com/31b7e1a2d874dc41d4a6

    • David Smith says

      March 29, 2016 at 8:02 am

      Hi Guido, thanks for sharing! In this case, the GFCommon::$tab_index is already global across all forms so you don’t need to do anything fancy to prevent tabindex conflicts when multiple Gravity Forms are on the same page.

    • Guido Pettinari says

      March 29, 2016 at 9:32 am

      Thank you David! You are right, It makes a lot of sense: Gravity Forms only needs a starting number for tabindex, and then it sorts it out automatically. Cool! I’ll revert my snippet to your original version :-)

  2. Simon says

    January 23, 2016 at 4:47 pm

    Maybe this is a new feature since you originally posted this article, but I found that adding a tabindex specification to the shorcode worked … like this: [gravityform id="1" tabindex="1000"]

    Reply
    • David Smith says

      January 23, 2016 at 4:57 pm

      Hi Simon, nope. You can set the tabindex from the shortcode since the early days of Gravity Forms. The benefit of this method is that you don’t have to set it on each shortcode. It works automatically for every form. Install and forget about it. :)

  3. Steve says

    January 5, 2016 at 4:39 pm

    Fixed tab order issues with 2 gravity forms on page. Thanks!

    Reply
    • David Smith says

      March 14, 2016 at 8:32 pm

      Awesome! Glad you found this useful. :)

  4. Steve says

    December 17, 2015 at 8:29 am

    Does this snippet also prevent tabbing jumping from one Gravity form to the next?

    (If so, i can’t get it to work).

    Thank you very much! Steve

    Reply
    • David Smith says

      December 17, 2015 at 8:42 am

      Hi Steve, no, this snippet actually helps with tabbing from one field to the next by avoiding issues where other elements on the page might have a tabindex that breaks the visual sequence of fields.

    • Steve says

      December 17, 2015 at 1:08 pm

      Hey David,

      Thank you for the fast response and the helpful information!

      Steve

  5. Nick says

    October 21, 2015 at 8:18 am

    October 2015 – still working! Cheers.

    Reply
    • David Smith says

      October 21, 2015 at 11:05 am

      Awesome, Nick. Thanks for confirming. :)

  6. Jamie says

    October 20, 2015 at 8:05 pm

    Perfect, thank you for this!

    Reply
    • David Smith says

      October 21, 2015 at 7:32 am

      My pleasure, Jamie. :)

  7. Stacy says

    September 9, 2015 at 9:04 am

    This worked like a charm, just a simple copy and paste! Thank you!

    Reply
    • David Smith says

      September 19, 2015 at 7:34 pm

      Awesome, happy to help! :)

  8. Jan says

    December 11, 2014 at 11:27 pm

    Thank you from the Philippines! :)

    Reply
  9. Neil Curtis says

    September 19, 2014 at 9:28 am

    Great, worked perfectly. I was trying to use this code (below) but it wasn’t really working for me.

    Thanks a lot,

    Neil

    Reply
    • David Smith says

      September 19, 2014 at 10:57 am

      Great! It looks like your code was stripped out but I’m glad this solution worked for you.

  10. Huw Rowlands says

    August 27, 2014 at 5:31 am

    Thanks for this. Worked first time like a charm. Excellent.

    Reply
    • David Smith says

      August 27, 2014 at 3:43 pm

      Glad to hear it, Huw!

  11. Chris Van Patten says

    April 14, 2014 at 11:27 am

    Brilliant – works like a charm with no further futzing around! Rocket Genius should really integrate this into their code. Seems like a silly bug to not fix.

    Reply
    • David Smith says

      April 15, 2014 at 9:02 am

      Glad it worked well for you. :)

  12. Howard says

    March 24, 2014 at 5:01 pm

    You are a genius! Thanks for sharing this with everyone! :D

    Reply
  13. Viral says

    March 21, 2014 at 3:14 am

    THanks buddy

    Reply
  14. Surbma says

    February 19, 2014 at 4:20 am

    Hi,

    thank you for this fix! It is working perfectly! :)

    Reply
    • David Smith says

      February 19, 2014 at 6:34 am

      Great! Glad you found this useful. :)

  15. Liam says

    January 29, 2014 at 4:22 am

    Thank you.

    Reply
  16. Tyler Lee says

    January 27, 2014 at 6:09 pm

    Thank you! It worked like a charm for my client.

    Reply
    • David Smith says

      January 27, 2014 at 6:11 pm

      Glad to hear it!

  17. Cracki says

    April 21, 2013 at 10:58 am

    hi how we can add new field to GF like “Ranking field” here: https://docs.google.com/forms/d/1wQ_akvbspn6KEeyuato4PiJ1nkeaxjfLKAjxGLilL14/viewform

    Reply
Newer Comments »

Trackbacks

  1. How to fix tabindex conflict in Gravity form. - WP Task Force Your One-stop Wordpress Solution - Outsource Wordpress Developer & Designer says:
    August 29, 2014 at 9:44 pm

    […] This script is from this SIte. for further explaination visit […]

    Reply
  2. OSX Keyboard settings making GravityForms in Safari look bad… | a blog by Mike Seyfang says:
    August 20, 2014 at 9:11 am

    […] The form at xyz does have the tabindex attributes, the issue now is a tabindex conflict. Try increasing the tabindex on the form either on the shortcode or using the following: https://gravitywiz.com/fix-gravity-form-tabindex-conflicts/ […]

    Reply
  3. Gravity Forms and Tab Index | TTI COM Visual Media says:
    May 16, 2013 at 3:20 pm

    […] Gravity Wiz, maybe we need to include this with every site that uses Gravity Forms and a Comment box on the […]

    Reply

Leave a Reply Cancel reply

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

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Recent Posts

  • Our 46th perk is here. Say hello to Advanced Save & Continue.
  • Introducing Page Transitions 1.0 📖
  • Gravity Forms QR Code turns 1.0 🎉
  • How to Filter One Field By Another and Create Gravity Forms Chained Selects
  • Gravity Forms OpenAI

Categories

  • How To (78)
  • News (25)
  • Plugins (21)
  • Releases (19)
  • Resource (4)
  • Snippets (54)
  • Spotlights (18)
  • Tutorials (58)
  • Updates (177)

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2023 · Powered by WordPress · Gravity Wiz LLC

  • Support
  • Affiliates
  • About
  • Sitemap
  • Terms & Conditions of Use
  • Privacy Policy
  • Cookies Policy