0

Есть несколько input type="text" в форме

нужно чтобы когда поле пустое - один фоновой цвет, а когда заполнено хотя бы одним символом - другой цвет. Пробую так:

.block input
{
    outline: none;
    background-color: #9ed6a3;
}

.block input:not(:empty) 
{
    outline: none;
    background-color: #fff;
}

:not(:empty) работать не хочет, что я делаю не так?

0

1 ответ 1

8

в css3/html5 есть invalid/required http://jsfiddle.net/oceog/Mc72q/

HTML:

<input type="text" required />
<input type="text" required />    
<input type="text" required />

CSS:

input:invalid {
    background-color: red;
}

описание

насчет :empty - input всегда empty,медитировать на

<input type="text" />
1

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.