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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:38:00+00:00 2026-05-14T23:38:00+00:00

I am using ASP.NET MVC 2. Html.DropDownListFor and Html.TextAreaFor automatically get red borders when

  • 0

I am using ASP.NET MVC 2.

Html.DropDownListFor and Html.TextAreaFor automatically get red borders when the validation fails.

How to make the four borders of a TextBox (using Html.TextBoxFor) red when it fails validation?

For example, I have a TextBox that is required and when the user submits the form without specifying a value in the textbox, I want the textbox to have red borders.

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

    When validation fails for a model property – it’ll add a class to the input in the html. Have a look at the rendered html when the validation fails (using view source or firebug) and check out the class for your input*. Then edit your css to include a style for the failed validation.

    E.g. In my project I have:

    input.input-validation-error,
    textarea.input-validation-error,
    select.input-validation-error
    {
        background: #FEF1EC;
        border: 1px solid #CD0A0A;
    }
    

    HTHs,
    Charles

    * I’m pretty sure ASP.NET MVC add the class input-validation-error by default.

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

Sidebar

Related Questions

I'm running into a problem with using Html.DropDownListFor() with jQuery. I'm using ASP.NET MVC
I'm developing a mobile app using ASP.Net MVC to generate HTML 5 pages. The
I'm using ASP.NET MVC 3 and the helper @Html.Raw in my view. I'm passing
ASP.NET MVC can generate HTML elements using HTML Helpers, for example @Html.ActionLink() , @Html.BeginForm()
In my asp.net MVC app, I'm using a HTML text input, while I apply
I have an ASP.NET MVC form laid out something like this: @using (Html.BeginForm(null, null,
I'm using some javascript/jquery in an asp.net mvc view and I'm appending some html
I'm trying to output the following html using an html helper in asp.net mvc
Using ASP.NET MVC when trying to get the information stored on my Session[objectName] from
Using ASP.NET MVC 2 and and Html.RenderAction in my masterpage implemented as below throws

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.