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 6770171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:16:49+00:00 2026-05-26T15:16:49+00:00

Is it possible to get jquery validation to show the validation summary using eager

  • 0

Is it possible to get jquery validation to show the validation summary using eager validation?

I’m using MVC 3 (if it matters) and my forms validate when each element loses focus:

$('#myform').validate({ onfocusout: function(element) { $(element).valid(); } };

This shows individual errors on each field, however I also want to show those errors in the validation summary block. However, that validation summary only shows up when the form is submitted, not on lost focus.

I’ve tried hooking into showErrors, however that only gives me the current field error, not the current list of errors.


For completeness, here’s the form code:

@using (Ajax.BeginForm(...))
{

  <div class="field-panel">
    @Html.EditorFor(m => m.PatientID)
    ...

  </div>
  <input type="submit" class="carecon-button-next" value="Next" />
  @Html.ValidationSummary(null, new { @class = "validation-summary" })
}
  • 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-05-26T15:16:50+00:00Added an answer on May 26, 2026 at 3:16 pm

    Ok, I think I figured this out.

    The issue is actually due to using the unobtrusive validation with MVC 3, since it does the jQuery validation initialization for you. Thus the only way to configure validation is by using form.data("validator").settings. However, trying to set the errorLabelContainer via this method, i.e.:

    $("#form").data("validator").settings.errorLabelContainer = "#messageBox";
    

    … doesn’t work, because jQuery’s validation only uses this value internally in it’s init() function, to configure a bunch of other settings like containers , etc. I tried emulating what it does, or even calling $("#form").data("validator").init() again after setting the errorLabelContainer, but doing so caused weird behavior and hosed a bunch of other settings.

    So I took a different approach. First, I provided a place for MVC to put in the individual error strings using @Html.ValidationMessageFor(), and adding display:none to keep it hidden:

    @using (Ajax.BeginForm(...))
    {
    
      <div class="field-panel">
        @Html.EditorFor(m => m.PatientID)
        @Html.ValidationMessageFor(m => m.PatientID, null, new { style = "display:none"})
        ...
    
      </div>
      <input type="submit" class="carecon-button-next" value="Next" />
      <ul id="error-summary">
      </ul>
    }
    

    Then, in the showErrors callback, I copy those strings in to the validation summary after calling defaultShowErrors():

        $("#form").data("validator").settings.onfocusout = function (element) { $(element).valid(); };
        $("#form").data("validator").settings.showErrors = function (errorMap, errorList) {
            this.defaultShowErrors();
            $("#error-summary").empty();
            $(".field-validation-error span", $("#form"))
                .clone()
                .appendTo("#error-summary")
                .wrap("<li>");
    
        };
    

    This gave me the behavior I wanted, showing/hiding the validation errors as a list in the summary as the user filled out the fields on the form.

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

Sidebar

Related Questions

Is it possible to get the top position of an element using javascript/jquery ?
Is it possible to get a particular value out of viewstate using JQuery.... I'm
Ello, I'm using jQuery-Validation-Engine and i don't know if this is currently possible but,
Using the jQuery Validation plug-in for the following form: <form id=information method=post action=#> <fieldset>
I am using the popular jQuery Validation Plugin . It's very flexible with regards
In VS2010 and ASP.NET MVC 2, it seems that client-side validation (JQuery Futures or
Possible Duplicate: jQuery get input value after keypress I'm trying to get an input
Is it possible to get jQuery to do the same job as nth:child(odd)? So
Possible Duplicate: get querystring with jQuery How do I get the value of a
Is it possible to get some created tags with jquery For example : $(function()

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.