Skip to content

Instantly share code, notes, and snippets.

@oscarCrespo
Last active February 3, 2016 17:55
Show Gist options
  • Save oscarCrespo/0610a5f0776ea84f89ad to your computer and use it in GitHub Desktop.
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
/* 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