Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize asp.net MVC validation message position

i am doing MVC model validation through data annotation and my validation message is showing just at right side of input but i want to show it at the below of input box like the screen shot. enter image description here

so just tell me what i need to do without touching html. thanks

like image 225
Mou Avatar asked Oct 19 '13 17:10

Mou


People also ask

How can show validation message in ASP.NET MVC?

Click on "Add". The Html. ValidationMessage() is an extension method, that is a loosely typed method. It displays a validation message if an error exists for the specified field in the ModelStateDictionary object.

How do you show custom validator error message in validation summary?

In order for the Validator 's error message to display in the ValidationSummary , you need to set the Validator s Display="none" . I also set Text="" . C.C. C.C.

Which property of validation attribute is used for displaying the custom error message?

You can provide a custom error message either in the data annotation attribute or in the ValidationMessageFor() method.


1 Answers

You can alter field-validation-error and validation-summary-errors classes in CSS to make them reside on a new line. One way is to make them block elements by using display:block style. Here is a sample CSS:

.field-validation-error {
    display: block;
}
like image 172
Sedat Kapanoglu Avatar answered Dec 10 '22 01:12

Sedat Kapanoglu