-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathindex.html
More file actions
147 lines (137 loc) · 4.26 KB
/
Copy pathindex.html
File metadata and controls
147 lines (137 loc) · 4.26 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!doctype html>
<html lang="en">
<head>
<title>ValidForm Examples Tho</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./site/style.css">
<script type="text/javascript" src="./dist/valid-form.js"></script>
<style media="screen">
form .form-control.invalid {
border-color: red;
}
/* Styling the validation errors */
.example-form .form-group {
position: relative;
}
.example-form .form-group .validation-error {
color: red;
font-size: 14px;
}
.example-form_before .form-group .validation-error {
position: absolute;
right: 0;
top: 1px;
}
</style>
</head>
<body>
<div class="container">
<div class="navbar">
<a class="navbar__brand" href="https://pageclip.co">
<img src="./site/mark-gradient.png">
</a>
</div>
<h1>ValidForm</h1>
<p>
ValidForm is a thin JavaScript wrapper around the HTML5 Form Validation
features. <a href="https://github.com/Pageclip/valid-form">Check out the
code →</a>
</p>
<p>
Submit these forms with no input, then mess with the input to get a feel for how
they behave.
</p>
<!-- Example 1 -->
<h2>Default Example</h2>
<div class="example-form example-form_before">
<div class="example-title">Example</div>
<form method="post" action="/">
<div class="form-group">
<label>Your Email</label>
<input
required
class="form-control"
type="email"
name="email"
pattern="[ab]+@.+"
data-valueMissing="Need an email!"
data-patternMismatch="Only a and b characters allowed!"
placeholder="a@b.com" />
</div>
<div class="form-group">
<label>Favorite Animal</label>
<select required class="form-control" name="animal">
<option value="">pick one!</option>
<option value="cat">Cat</option>
<option value="dog">Dog</option>
<option value="catdog">Catdog</option>
</select>
</div>
<div class="form-group">
<label>A Story</label>
<textarea
required
class="form-control"
name="story"
pattern="[ab ]+"
rows="4"
data-valueMissing="Write me a story plz"
data-patternMismatch="Plz only a and b characters!"
placeholder="Tell me a story!"></textarea>
</div>
<button type="submit">Submit</button>
</form>
</div>
<h2>Example With Errors After</h2>
<div class="example-form example-form_after">
<div class="example-title">Example</div>
<form method="post" action="/">
<div class="form-group">
<label>Your Email</label>
<input
required
class="form-control"
type="email"
name="email"
pattern="[ab]+@.+"
data-patternMismatch="Only a and b characters allowed!"
placeholder="a@b.com" />
</div>
<div class="form-group">
<label>Favorite Animal</label>
<select required class="form-control" name="animal">
<option value="">pick one!</option>
<option value="cat">Cat</option>
<option value="dog">Dog</option>
<option value="catdog">Catdog</option>
</select>
</div>
<div class="form-group">
<label>A Story</label>
<textarea
required
class="form-control"
name="story"
pattern="[ab ]+"
rows="4"
data-valueMissing="Write me a story plz"
data-patternMismatch="Plz only a and b characters!"
placeholder="Tell me a story!"></textarea>
</div>
<button type="submit">Submit</button>
</form>
</div>
</div>
<script>
var forms = document.querySelectorAll('.example-form_before form')
forms.forEach(function (form) {
ValidForm(form)
})
var forms = document.querySelectorAll('.example-form_after form')
forms.forEach(function (form) {
ValidForm(form, {errorPlacement: 'after'})
})
</script>
</body>
</html>