Created
October 15, 2016 13:02
-
-
Save Hube2/d4cee2ac6102589dbe8e5ed414454bff to your computer and use it in GitHub Desktop.
Cause Tab where error is located to be focused in ACF
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
acf.add_filter('validation_complete', function( json, $form ){ | |
if(json.errors) { | |
var field = jQuery('[name="' + json.errors[0].input + '"]', $form).parents('.acf-field'); | |
field = field[field.length - 1]; | |
var tab = jQuery(field, $form).prev('.acf-field-tab').attr('data-key'); | |
jQuery('.acf-tab-wrap a[data-key=' + tab + ']', $form).click(); | |
} | |
return json; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment