-
Notifications
You must be signed in to change notification settings - Fork 27.1k
/
form-validation.html
77 lines (69 loc) · 1.48 KB
/
form-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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Form validation example</title>
<style>
html {
font-family: sans-serif;
}
form {
background: #eee;
border-radius: 20px;
box-shadow: 1px 1px 1px black;
padding: 20px;
width: 300px;
}
label {
width: 130px;
float: left;
text-align: right;
padding: 4px;
margin-bottom: 20px;
}
input {
width: 130px;
float: right;
}
label, input {
font-size: 1em;
line-height: 1.5;
}
div {
clear: both;
}
.errors {
background: yellow;
border-radius: 20px;
box-shadow: 1px 1px 1px black;
padding: 20px;
width: 300px;
position: absolute;
left: 360px;
}
</style>
</head>
<body>
<h1>Form validation example</h1>
<div class="errors" role="alert" aria-relevant="all">
<ul>
</ul>
</div>
<form>
<div>
<label for="name">Enter your name:</label>
<input type="text" name="name" id="name">
</div>
<div>
<label for="age">Enter your age:</label>
<input type="number" name="age" id="age">
</div>
<div>
<input type="submit">
</div>
<div></div>
</form>
<script src="validation.js"></script>
</body>
</html>