Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8226651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:50:55+00:00 2026-06-07T15:50:55+00:00

I am using jQuery accordion to split my forms into several panels and jQuery

  • 0

I am using jQuery accordion to split my forms into several panels and jQuery validation to check the required fields. It works great to show errors in validated fields as long as they are in the open panel.

An example. Let’s say I have three accordion panels and on the first I have two form fields that need to be validated. Now, if the visitor switches to panel two or three and submits the form without without filling in the required fields on panel one I want the first accordion panel to open up and show the errors.

Does anybody know a way to make this work?

This is the code I’m using today:

$(document).ready(function() {
$("#accordion").accordion({
    autoHeight: false,
    navigation: true,
});

$("#validate_form").validate({
    rules: {
        page_title: "required",
        seo_url: "required",
        AccordionField: {
            required: true
        }
    },
    ignore: [],
    messages: {
        page_title: "Please enter a page title",
        seo_url: "Please enter a valid name"
    }
 }); 
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:50:57+00:00Added an answer on June 7, 2026 at 3:50 pm

    To solve the specific problem in your question, you only have to provide a an invalidHandler callback function that calls the activate() method of the accordion widget to open the first pane:

    $("#validate_form").validate({
        // your options,
        invalidHandler: function(form, validator) {
            if (validator.numberOfInvalids() > 0) {
                $("#accordion").accordion("activate", 0);
            }
        }
    });
    

    That said, handling the general case (invalid elements on any pane) and switching to the appropriate pane would arguably be better. To do that, we have to fetch the first invalid element from the invalidHandler callback. We can match the errorClass used by the validation engine (error by default), however we cannot blindly match that because that class is also applied to the error message labels. Restricting the results with a :input selector will help us here.

    From there, we can use closest() to match the ancestor accordion pane, and index() to obtain its index relative to the other panes, which leads us to the following code:

    $("#validate_form").validate({
        // your options,
        invalidHandler: function(form, validator) {
            if (validator.numberOfInvalids() > 0) {
                validator.showErrors();
                var index = $(":input.error").closest(".ui-accordion-content")
                                             .index(".ui-accordion-content");
                $("#accordion").accordion("activate", index);
            }
        }
    });
    

    Update: We also have to call showErrors() explicitly in our invalidHandler, since this function is responsible for decorating the invalid elements with the error class in the first place, but is normally only called afterwards. (Source: http://forum.jquery.com/topic/jquery-validate-invalidhandler-is-called-before-the-errors-are-shown-maybe-better-vice-versa.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basic form using a JQuery Accordion and attempting to validate required fields. Am I
I'm using both the jQuery UI accordion and the datepicker. The accordion works great,
I have a standard jquery ui accordion and I load content into it using
I'm using jquery + the accordion plugin. That's working great. Now, I want another
I am using JQuery Accordion and it works as it should and opens and
I am using JQuery Accordion. I have this page here: http://www.hauppauge.com/site/support/support_colossus.html#tabs-6 What happens is
I am using jQuery Accordion here and find some strange behavior when opening a
http://mindfulintegrations.com/signiacapital/accordian.php I am using Jquery Accordion UI and if you look at the above
I am using the jQuery accordion plugin to make an accordion of some data.
I'm using the JQUERY UI Accordion module: <script type=text/javascript> $(function() { $(#sidebar_column_accordion).accordion({ fillSpace: true,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.