How do I highlight a textbox border red when it is required?

后端 未结 5 1855
谎友^
谎友^ 2020-12-05 05:52

What property do I use on the required field validator control to make the textbox red if there is a validation error?

Here is my code:



        
5条回答
  •  借酒劲吻你
    2020-12-05 06:24

    Without overloading anything, give your tags a CssClass="garbage" attribute.

    In your style sheet, create

    .garbage {
        display: none;
    }
    .garbage[style*=visible] + input,
    .garbage[style*=visible] + select,
    .garbage[style*=visible] + textarea {
        background-color: #ffcccc;
        border: 1px solid #ff0000;
    }
    

    and any form control immediately preceded by a validator will be highlighted on invalid data.

    EDIT:

    I've seen a few methods for forcing a redraw in Chrome, including a pure css solution: transform: translateZ(0);

提交回复
热议问题