Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing class definition for "input-validation-error" inside a new asp.net mvc-5 web application

I have created a new asp.net mvc-5 web application using VS 2013. now when i try the built-in login form and i leave the required fields empty i got the following, :-

enter image description here

where both fields were not highlighted with red color as i use to get inside previous versions of asp.net mvc. now from the generated markup i can inspect that any field that have validation errors will have the following class:-

input-validation-error

But i search the whole css files which are generated automatically inside my asp.net mvc-5 web application mainly; site.css , bootstrap.css bootstrap.min.css , but i could not find a definition for the input-validation-error ?? so can anyone advice on this please, how i can highlight the fields with red color if they have validation error , and why this is not the default behavior inside asp.net mvc-5 ?

like image 604
john Gu Avatar asked Nov 02 '15 15:11

john Gu


People also ask

Which attribute is used for input validation in ASP.NET MVC?

ComponentModel. DataAnnotations namespace. These attributes are used to define metadata for ASP.NET MVC and ASP.NET data controls. You can apply these attributes to the properties of the model class to display appropriate validation messages to the users.

Where is data validation in MVC?

You validation should be in Model section of MVC. As models have various fields, only models can know what combination of inputs make that model valid.


1 Answers

why this is not the default behavior inside asp.net mvc-5

It's not default behavior of ASP.NET MVC 5. You just need to add following css classes in Site.css file.

.field-validation-error {
    color: #e80c4d;
    font-weight: bold;
}

.field-validation-valid {
    display: none;
}

input.input-validation-error {
    border: 1px solid #e80c4d;
}

.validation-summary-errors {
    color: #e80c4d;
    font-weight: bold;
    font-size: 1.1em;
}

.validation-summary-valid {
    display: none;
}
like image 89
Sandeep Shekhawat Avatar answered Oct 27 '22 19:10

Sandeep Shekhawat