forked from twbs/bootstrap-sass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.html
135 lines (122 loc) · 4.14 KB
/
form.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="dist/app.css" />
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.1.0/css/all.css"
integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt"
crossorigin="anonymous"
/>
<link rel="icon" type="image/x-icon" href="assets/images/favicon.ico" />
<script
defer
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"
></script>
<script
defer
type="text/javascript"
src="assets/javascripts/bootstrap.js"
></script>
<script defer src="FormValidator.js"></script>
<title>Exemplar Form</title>
</head>
<body>
<main class="container">
<h1>Exemplar Form</h1>
<div class="row">
<div class="col-md-6">
<h2>Form</h2>
<form id="registration" novalidate class="needs-validation">
<div tabindex="-1" role="group" id="errorSummary" class="alert alert-danger errorSummary hidden"></div>
<div class="help-block">
Enter your name to help complete this form
</div>
<fieldset>
<legend>Your details</legend>
<div class="form-group field">
<label for="name">
<span class="field-label">Name <span class="field-required">(Required)</span></span>
<span class="field-hint">Sort it out</span>
</label>
<input
class="form-control"
type="text"
id="name"
autocomplete="given-name"
required
/>
</div>
<div class="form-group field">
<label for="email">
<span class="field-label">Email <span class="field-required">(Required)</span></span>
</label>
<input
class="form-control"
type="email"
id="email"
autocomplete="email"
required
/>
</div>
<div class="form-group field">
<label for="email">
<span class="field-label">Password</span>
</label>
<input
class="form-control"
type="password"
name=""
id="password"
autocomplete="current-password"
/>
</div>
</fieldset>
<div class="form-group field">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="personal-details" required>
<label class="custom-control-label" for="personal-details">I hereby agree to give away all my personal details, in perpetuity.</label>
</div>
</div>
<div class="controls">
<button type="submit" class="btn btn-primary">Login</button>
<button type="reset" class="btn btn-default">Clear</button>
</div>
</form>
</div>
<div class="col-md-6">
<h2>Guidelines</h2>
<ol>
<li>
<code>novalidate</code> set on form to disable browser validation
</li>
<li>Top-aligned labels</li>
<li><code>autocomplete</code> attribute</li>
<li>All fields required by default</li>
</ol>
</div>
</div>
</main>
</body>
<script>
var forms = document.querySelectorAll('.needs-validation')
// Loop over them and prevent submission
Array.prototype.slice.call(forms)
.forEach(function (form) {
form.addEventListener('submit', function (event) {
if (!form.checkValidity()) {
event.preventDefault()
event.stopPropagation()
}
form.classList.add('was-validated')
}, false)
})
</script>
</html>