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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:24:12+00:00 2026-06-03T11:24:12+00:00

I am working on a mvc3 application and I need to modify the style

  • 0

I am working on a mvc3 application and I need to modify the style of the ValidatioSummary message, to do so, I created my own HTM helper which is as follows:

public static MvcHtmlString MyValidationSummary(this HtmlHelper helper){

    string retainHtml +="";
    int counterror = 0;
    if (helper.ViewData.ModelState..IsValid)
    {
       TagBuilder tag = new TagBuilder("div");
       tag.Attributes.Add("class", "validation-summary-valid");
       tag.Attributes.Add("data-valmsg-summary", "true");
       tag.InnerHtml += "<span> There was" + countererror + "errors found<ul><li></li></ul>"
       retainHtml += tag.ToString();
    
       return MvcHtmlString.Create(retainHtml);
    }

    if (!helper.ViewData.ModelState.IsValid)
    {
       TagBuilder tag = new TagBuilder("div");
       tag.Attributes.Add("class", "validation-summary-errors");
       tag.Attributes.Add("data-valmsg-summary", "true");
       retainHtml +="<div class='validation-summary-errors'><span>";   
       counterror = 1;
       string temretainhtml ="";

       foreach (var key in helper.ViewData.ModelState.keys)
       }
           foreach (var err in helper.ViewData.ModelState[key].Errors)
               temretainhtml += "<li>Error  " + countererror++ + "  :  "  + err.ErrorMessage + "</li>";
       }
      
       retainHtml += "Error ! there was " + --countererror  + " errors found";
       retainHtml += "</span>";
       retainHtml += "<ul>";
       retainHtml += temretainhtml;
       retainHtml += "</ul></div>";
       }
    return MvcHtmlString.Create(retainHtml);
   }
  }
 }

This works perfect with server side validation, but I need to implement this style on the Client side validation as well, right now, the forms are displaying the validationSummary on the top of the page on client side but with the default MVC format, not the one I specified in my HTML helper, I’ve been doing a lot of research but unfortunately I haven’t had any luck, may I need to do any change in the jquery.validate.unobtrusive.js file to apply these changes? or do I need to create another validation file in jquery? My experience in jquery is very poor and I am very lost right now, any help you can give me please it’ll be really appreciated.

Many thanks!!!

  • 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-03T11:24:18+00:00Added an answer on June 3, 2026 at 11:24 am

    Late answer:
    The jquery.validate.unobtrusive.js is hard to hook in to. Instead of modifying the file (never ideal) try this:

    Listen to the following event

    form.bind("invalid-form.validate", handler...
    

    And then then build your own summary:

    form.bind("invalid-form.validate", function (evt, validator) {
        var container = $(this).find("[data-valmsg-summary=true]");
        var list = container.find("ul");
    
        if (list && list.length && validator.errorList.length) {
            list.empty();
            container.addClass("validation-summary-errors").removeClass("validation-summary-valid");
    
            $.each(validator.errorList, function () {
                $("<li style='color:#00aa00'/>").html(this.message).appendTo(list);
            });
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an MVC3 Razor web application which gets it's page decoration from
I'm working on Asp.net MVC3 web application. I'm having one page on which appx.
I'm working on a MVC3 application and I created my POCO classes from my
I have been working on mvc3 application and trying to localize the same. I
I am working on an MVC3 application using the Razor syntax and I have
I've been working on writing my first MVC3 application for a little while and
I'm currently working on my first MVC3 application at work (using the Razor view
I'm working on ASP.net MVC3 Web application that is facing scalability issue. For improving
I am working on a MVC3 code first web application and after I showed
I am working on a MVC3 application with entity framework and SQL Server 2008.

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.