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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:52:36+00:00 2026-06-10T11:52:36+00:00

Im new to mvc and have several questions about asp mvc 3 validation, help

  • 0

Im new to mvc and have several questions about asp mvc 3 validation, help regarding any of those would be apreciated:

First I have a model class that requires some fields to be present like this:

[Required(ErrorMessage = "Required field")]
public UInt16 SomeField { get; set; }

It’s working but the error message is apearing in black font (i want it red), and i think that the validation is taking plance on the server side instead of on the client, i’ve been reading some tutorials about how to make javascript validation work but it’s not working apparently:

Web.config

<appSettings>
  <add key="ClientValidationEneabled" value="true" />
  <add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>

Index.cshtml

<script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
@{ Html.EnableClientValidation(); }

That would be my second question, make it work on the client side.

And for some fields that have the Required validator and have a set of radio buttons asociated with them like this

model

[Required(ErrorMessage = "Required field")]
public UInt16 SomeField { get; set; }

view

@Html.RadioButtonFor(model => model.SomeField, 1) Label
@Html.RadioButtonFor(model => model.SomeField, 2) Label
@Html.ValidationMessageFor(model => model.SomeField)

the validation message is not showing up (even on black font) when you miss to click a radio button, how you can make it show when there are not pressed buttons.

ASP MVC 3
Razor engine

  • 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-10T11:52:38+00:00Added an answer on June 10, 2026 at 11:52 am

    Microsoft*.js scripts are deprecated in ASP.NET MVC 3 and should no longer be used. You can completely get rid of them. They are provided only for backwards compatibility if you are upgrading an older application. The same stands true for the Html.EnableClientValidation(); helper. They were replaced by jquery.validate plugin and the unobtrusive validation scripts.

    And since you have enabled unobtrusive validation in your web.config all you need in order to enable client side validation in an MVC 3 application is to include the jquery.validate.js and jquery.validate.unobtrusive.js scripts, along with the version of jquery that you are using of course because both those scripts depend on it.

    <script type="text/javascript" src="@Url.Content("~/scripts/jquery-1.5.1.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/scripts/jquery.validate.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/scripts/jquery.validate.unobtrusive.js")"></script>
    

    Another remark about your code is the [Required] attribute that you applied to a non-nullable type (ushort). This makes no sense because non-nullable types, by their very nature, always have value. The Required attribute should be used only on nullable types, for example:

    [Required(ErrorMessage = "Required field")]
    public ushort? SomeField { get; set; }
    

    As far as the color of the validation message is concerned, both client side and server side validation uses the same HTML structure. So it’s really a matter of CSS to design the look and feel of those messages.

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

Sidebar

Related Questions

I am knee deep in starting a new ASP.NET MVC project. Several tutorials have
I have a new asp.net mvc project and i am trying to figure out
I have an ASP.NET MVC application that uses jQuery 1.3.2. On several of the
I have a controller in an ASP.NET MVC application. The page has several filters
I am new to MVC and have a grasp of the basic model, but
I have started a new mvc project and clicked on project\properties\web - use local
I am new to MVC and EF and I have a question. I have
Pretty new to MVC and the like. I have a class the looks like
New to MVC, so hopefully this will be pretty simple. I have an HTML
I’m fairly new at C# and MVC and have used lambdas on certain occasions,

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.