Last active
February 3, 2016 17:55
-
-
Save oscarCrespo/0610a5f0776ea84f89ad to your computer and use it in GitHub Desktop.
Fix the tab index issues when using more than one gravity form on a single page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Fix the tab index issues when using more than one gravity form on a single page */ | |
(function($){ | |
var $forms=$('form'); | |
var form_qty=0; | |
for (i in $forms){ | |
var formType = $forms.eq(i).attr('method'); | |
if (formType == 'post'){ | |
form_qty ++ | |
} | |
} | |
if (form_qty > 1) { | |
for (var j = 1; j <= form_qty-1; j++) { | |
var tabNumber = 10+j*10; /*Get a number higher than the number on tab index in the previous form.*/ | |
$forms.eq(j).find('input').each(function(){ | |
$(this).attr('tabindex', tabNumber) | |
}) | |
$forms.eq(j).find('textarea').each(function(){ | |
$(this).attr('tabindex', tabNumber) | |
}) | |
}; | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment