Red frame around TextBox when validation fails

I am using ASP.NET MVC 2.

Html.DropDownListFor and Html.TextArea For automatically getting red borders when validation fails.

How to make the four borders of a TextBox (using Html.TextBoxFor) red if 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 text box, I want the text box to have red borders.

+3
source share
2 answers

- ​​ html. html, ( firebug) *. css, .

. :

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

HTHS,

* , ASP.NET MVC input-validation-error.

+21

, , CSS :

.input-validation-error {
    border: 1px solid #ff0000;
    background-color: #ffeeee;
}
+2

Source: https://habr.com/ru/post/1745357/


All Articles