-
Notifications
You must be signed in to change notification settings - Fork 0
/
HTML-input-validation.html
51 lines (47 loc) · 1.09 KB
/
HTML-input-validation.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Input Validation</title>
<style>
div {
margin-bottom: 20px;
position: relative;
}
input + span {
padding-right: 30px;
}
input:invalid+span:after {
position: absolute;
content: '✖';
padding-left: 2px;
}
input:valid+span:after {
position: absolute;
content: '✓';
padding-left: 2px;
}
</style>
</head>
<body>
<form>
<div>
<label for="uname">Choose a username: </label>
<input type="text" id="uname" name="name" pattern="[a-z]{4,10}" required>
<span class="validity"></span>
</div>
<div>
<label for="password">
Pin:
</label>
<input type="password" name="" id="" required minlength="4">
<span class="validity"></span>
<p>Usernames must be lowercase and 4-8 characters in length.</p>
</div>
<div>
<button>Submit</button>
</div>
</form>
</body>
</html>