Home › Forums › Front-end Issues › Sending user to Tab on validation errors › Reply To: Sending user to Tab on validation errors
@marcelo2605 thanks for your solution.
This one also works for repeater fields:
jQuery(document).ready(function ($) {
acf.add_filter('validation_complete', function (json) {
if (json.errors) {
$.each(json.errors, function (index) {
var field = $('[name="' + json.errors[index].input + '"]').parents('.acf-field');
var repeater = field[1];
var previous_tabs = $(repeater).prevAll('[data-type="tab"]');
var tab_data_key = $(previous_tabs[0]).attr('data-key');
$('.acf-tab-wrap a[data-key=' + tab_data_key + ']').click();
});
}
return json;
});
});
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.