This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=<device-width>, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
<link href="https://fonts.googleapis.com/css?family=Maven+Pro:900|Overpass" rel="stylesheet"> | |
<title>HTML + CSS From Validation</title> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background: linear-gradient(125deg, #9683EE, #3F4FDA); | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
min-height: 100vh; | |
color: #65449B; | |
} | |
button { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
formInput.addEventListener('focus', () => { | |
if (formInput.valid) { | |
// Validaton - value correct | |
} else { | |
// Validaton - value incorrect | |
} | |
}); | |
submitButton.addEventListener('click', (event) => { | |
event.preventDefault(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="form__field"> | |
<input type="text" class="form__field__input" name="firstName" placeholder=" " pattern="[A-Za-z]{2,99}" required> | |
<label for="firstName" class="form__field__label">First Name</label> | |
<p class="form__field__error">Is your First Name correct?</p> | |
<div class="form__field__state-icon"></div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="text" class="form__field__input" name="firstName" placeholder=" " pattern="[A-Za-z]{2,99}" required> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.form__field__input ~ .form__field__state-icon { | |
color: red; | |
} | |
.form__field__input + .form__field__label { | |
color: red; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.form__field__input:focus + .form__field__label, | |
.form__field__input:valid + .form__field__label, | |
.form__field__input:invalid + .form__field__label { | |
top: -.5rem; | |
font-size: .6rem; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Zmodyfikowany styl | |
.form__field__input:invalid + .form__field__label { | |
top: -.5rem; | |
font-size: .6rem; | |
} | |
// Oryginalny styl - reset modyfikacji jeśli placeholder istnieje | |
.form__field__input:placeholder-shown + .form__field__label { | |
top: .35rem; | |
font-size: 1rem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 0-1-0 + 0-1-0 + 0-1-0 = 0-3-0 | |
.form__field__input:placeholder-shown + .form__field__label { | |
color: red; | |
} | |
// 1-0-0 + 0-0-1 + 0-0-1 = 1-0-2 | |
#wrapper ul li { | |
color: red; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.old-input[type="text"], | |
.old-input[type="email"], | |
.old-input[type="number"] { | |
color: red; | |
} |
OlderNewer