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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:24:07+00:00 2026-05-27T23:24:07+00:00

I am trying to override the default validation css class for validators which is

  • 0

I am trying to override the default validation css class for validators which is “field-validation-error” class

So, if I write a Validation message for a input on my form as below:

@Html.ValidationMessageFor(m=>m.Name)

Then the MVC runtime is setting the class of the message span by default as below:

<span class="field-validation-error" data-valmsg-replace="true" data-valmsg-for="Name">

My question is, how can I remove the css class “field-validation-error” and replace it with another class (my version) which i will be using it in only some areas of my application.

  • 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-27T23:24:08+00:00Added an answer on May 27, 2026 at 11:24 pm

    Ok…so I got it working by setting the base “field-validation-error” class as “form .field-validation-error” in the root css file…which means that this class will have the highest priority when the Html is generated and then in my View I included the new css class as mentioned below:

    @Html.ValidationMessageFor(m=>m.Name, new { @class ="NewCssClass"})
    

    This will generate the below markup:

    <span class="field-validation-error NewCssClass" data-valmsg-replace="true" data-valmsg-for="Name">
    

    As you can see the NewCssClass will override the default validation style specified in the “field-validation-error” class…

    Cheers…

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

Sidebar

Related Questions

In ASP.NET MVC3 I'm trying to set the css class that the validation error
I am trying to override the Page_PreInit function inside my class _Default which inherits
I'm trying to override the default behavior in a UITableView (which is in fact
I am trying to override the DataGridViewTextBoxCell's paint method in a derived class so
I'm trying to override the default DatePicker template in Silverlight. I want to remove
I am trying to override the default page setup margins for my users. The
I am trying to override the jQuery ajax function to handle a default action
I'm trying to make an application where the user can override the default behaviour
I'm trying to override the default category view in Satchmo. I'm successfully overriding other
I am trying to override the DateTime template since I need custom class names

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.