Support

Account

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;
        });
    });