开发者

Style HTML5 input types if validation fails

Yo everyone

My question is quite simple: I need to style the red border (or shadow?) of the inputs that couldn't be validated (like email). Is there any new CSS trick to do that?

If you still don't understand what I am telling you, then this is the开发者_开发百科 color that needs changing:

Style HTML5 input types if validation fails


See https://developer.mozilla.org/en/CSS/%3Ainvalid for Firefox details, although presumably the parts without "-moz" apply to other browsers too:

The :invalid CSS pseudo-class is applied automatically to <input> elements whose contents fail to validate according to the input's type setting. This allows you to easily have invalid fields adopt an appearance that helps the user identify and correct errors.

By default, Gecko does not apply a style to the :invalid pseudo-class. However it does apply a style (a red "glow" using the box-shadow property) to the :-moz-ui-invalid pseudo-class, which applies in a subset of cases for :invalid.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜