Code Examples
<!-- Required + length limits -->
<input type="text" name="username"
required minlength="3" maxlength="20">
<!-- Email type validates format automatically -->
<input type="email" name="email" required>
<!-- Number ...
/* Only style after the user has interacted — */
/* :placeholder-shown = input is still empty */
input:valid:not(:placeholder-shown) {
border-color: #2de8c0; /* green border */
background: rgba(45,232,192,.05);
}
input:invalid:not(:placeholde...
<form id="myForm" novalidate>
<label for="em">Email</label>
<input type="email" id="em" name="email" required>
<span id="emErr" class="error"></span>
<button type="submit">Submit</button>
</for...