-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctionality.html
207 lines (191 loc) · 5.52 KB
/
functionality.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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<html>
<head>
<title>Functionality - You don't need JavaScript for that!</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="initial-scale=1, width=device-width" />
<link rel="stylesheet" href="css/functionality.css" />
</head>
<body>
<h1>Functionality with HTML5 <code><input></code></h1>
<p>
The live code example below is a form with several
<code><input></code> fields. HTML5 introduce new types of inputs
that provide UI, restrictions, validation, and error handling. The
functionality is so much that you can actually build and interactive form
with zero JavaScript!
</p>
<p></p>
<p>
View
<a
href="https://github.com/benmvp/you-dont-need-js-for-that/blob/master/functionality.html"
target="_blank"
>HTML</a
>
and
<a
href="https://github.com/benmvp/you-dont-need-js-for-that/blob/master/css/functionality.css"
target="_blank"
>CSS</a
>
code
</p>
<form class="form" method="GET" action="" autocomplete="off" novalidate>
<fieldset>
<legend>No JavaScript form</legend>
<div class="input-group">
<label class="main-label" for="name">Full Name*:</label>
<input
id="name"
name="name"
type="text"
class="input-text"
placeholder="Lisa Nguyen"
maxlength="50"
minlength="5"
required
title="Full name (1-50 characters)"
/>
</div>
<div class="input-group">
<label class="main-label" for="email">Email*:</label>
<input
id="email"
email="email"
type="email"
class="input-text"
placeholder="lisa.nguyen@fake.com"
maxlength="75"
minlength="5"
required
title="Email (5-75 characters)"
/>
</div>
<div class="input-group">
<label class="main-label" for="birthdate">Birthdate:</label>
<input
id="birthdate"
name="birthdate"
type="date"
class="input-text"
placeholder="01/01/1956"
pattern="^\d{2}/\d{2}/\d{4}$"
/>
</div>
<div class="input-group">
<label class="main-label" for="areacode">Phone Number*:</label>
(<input
id="areacode"
class="input-text areacode"
name="areacode"
type="tel"
placeholder="216"
minlength="3"
maxlength="3"
required
title="Area Code (3 digits)"
/>)
<input
type="tel"
class="input-text prefix"
name="prefix"
type="tel"
placeholder="123"
minlength="3"
maxlength="3"
required
title="Prefix (3 digits)"
/>
—
<input
type="tel"
class="input-text line"
name="line"
type="tel"
placeholder="4567"
minlength="4"
maxlength="4"
required
title="Line (4 digits)"
/>
</div>
<div class="input-group">
<label class="main-label" for="expertise">Web Expertise*:</label>
<input
id="expertise"
name="expertise"
class="expertise"
type="range"
placeholder="1 - 10"
min="1"
max="10"
step="1"
required
/>
</div>
<div class="input-group">
<label class="main-label" for="blog">Blog URL:</label>
<input
id="blog"
name="blog"
type="url"
class="input-text"
placeholder="http://www.benmvp.com"
/>
</div>
<div class="input-group">
<label class="main-label" for="fav-color">Favorite Color*:</label>
<input
id="fav-color"
name="favcolor"
type="color"
class="fav-color"
placeholder="#0fe48d"
required
pattern="#[0-9a-fA-F]{6}"
/>
</div>
<div class="input-group">
<label class="main-label" for="donation">Donation*:</label>
£
<input
id="donation"
name="donation"
type="number"
class="input-text"
min="5"
max="1000"
step=".5"
required
list="suggested-donations"
/>
<datalist id="suggested-donations">
<option>5</option>
<option>10</option>
<option>25</option>
<option>50</option>
<option>100</option>
<option> </option>
<option>250</option>
<option>500</option>
<option>1000</option>
</datalist>
</div>
<div class="input-group">
<button type="submit" class="submit">Submit!</button>
</div>
</fieldset>
</form>
<script src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
$('.form').submit(function (e) {
$(this).addClass('form-submitted')
if (!this.checkValidity()) {
e.preventDefault()
}
})
</script>
</body>
</html>