The :valid CSS pseudo-class represents any <input> or <form> element whose content validates correctly according to the input's type setting. This allows to easily make valid fields adopt an appearance that helps the user confirm that their data is formatted properly.

:valid {
    css declarations;
}
input:valid{
   color: #3366ff;
   background: #ffff99;
}

Click the button below to experiment with this selector.

Give it a Try!

4.0Firefox 10.0Explorer 10.0Chrome 5.0Safari 10.0Opera