Input-check-error css error for dropdowns

(Ok, it might be a duplicate, but searching did not lead me to any posts, so apologize in advance if there is a post in there)

I have a dropdown that lists the rows, selected by default. If the user submits the form using the Select Still Selected option, the model state is not executed and an error is reported. (Ok) however, I need a red border as well as an error. Css

 input.input-validation-error { border: 1px solid #f00; background-color: #fee; }
 textarea.input-validation-error { border: 1px solid #f00; background-color: #fee; } 

 // is it as easy as this? I am guessing its not "dropdown" or is a 10x more complicated?
 dropdown.input-validation-error { border: 1px solid #f00; background-color: #fee; }  

      

So how do I put a red border around the dropdowns?

Here is an example of a strongly typed dropdown menu

@Html.DropDownListFor(m => m.test.id, new SelectList(Model.test.list, "Id", "Name"), "Please Select")

      

thank

+3


source to share


1 answer


dropdown

is not a valid HTML element. select

is the correct element in this case:

select.input-validation-error { ... }

      

However, depending on the specifics of your selector, you could easily remove the element name entirely and just use:



.input-validation-error { ... }

      

It's worth noting anyway that multiple selectors can be given the same style by separating them with a comma, so you don't have to repeat the same style declarations over and over:

input.input-validation-error,
textarea.input-validation-error,
select.input-validation-error { ... }

      

+6


source







All Articles