Home >Web Front-end >CSS Tutorial >Introduction to css required, focus, valid and invalid

Introduction to css required, focus, valid and invalid

高洛峰
高洛峰Original
2016-10-29 13:41:541935browse

This article will introduce you to the method of defining required, focus, valid and invalid styles in CSS3. This method currently only supports ie9+ and ff, gg browsers.
css3 tip only applies to advanced browsers:
Chrome
Firefox
Safari
IE9+

Definitions of valid, invalid, and required

input:required, input:valid , input:invalid{  
    border:0 none;   
    outline: 0 none;   
    -webkit-box-shadow:none;   
    -moz-box-shadow:none;   
    -ms-box-shadow:none;   
    -o-box-shadow:none;   
    box-shadow: none;  
}  
/* by http://www.manongjc.com/article/1327.html */

In the past, the verification form would use js and regular expressions to determine whether the filled-in content was correct, such as email verification. .
The emergence of HTML5 provides us with some attributes that can solve the problem of checking the form content without writing js and regular expressions.
:required
Must, that means the input cannot be empty.
:valid
is valid, that is, it is triggered when the filled in content meets the requirements.
:invalid
Invalid, that is, triggered when the filled in content does not meet the requirements.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:display:boxNext article:display:box