-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
227 lines (197 loc) · 8.65 KB
/
index.html
File metadata and controls
227 lines (197 loc) · 8.65 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
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>bsValidate</title>
<script src="https://code.jquery.com/jquery-3.6.3.min.js"
integrity="sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"
integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct"
crossorigin="anonymous"></script>
<style>
label.required::after,
legend.required::after {
content: "*";
color: red;
font-weight: bold;
margin-left: 2px;
}
</style>
<script src="jquery.bsValidate.js" type="text/javascript"></script>
<script>
$(function () {
$(document).on('submit', '#addUser', function (event) {
event.preventDefault();
$(this).find('.bs-validate').trigger('submit');
if (!this.checkValidity()) {
return;
}
alert('this form is valid');
this.reset();
});
$(document).on('reset', '#addUser', function (event) {
$(this).find('.bs-validate').trigger('reset');
});
});
const onValid = {
spinner: function (el) {
el.showSpinner();
new Promise((resolve) => setTimeout(resolve, 3000))
.then(() => {
console.log(el);
el.removeSpinner()
});
}
}
const outputValueToConsole = function (el) {
console.log(el.val());
}
</script>
</head>
<body>
<div class="container-fluid px-5 pt-3">
<div class="h3">bsValidate</div>
<div class="card">
<div class="card-body p-5">
<form id="addUser" autocomplete="off" action="" novalidate>
<fieldset>
<div class="form-group row">
<label for="firstName" class="col-2 col-form-label">First Name</label>
<div class="col">
<input type="text" class="form-control bs-validate" name="firstName" id="firstName" minlength="2"
maxlength="40" data-hint="2 to 40 charcters required" data-hint-on-focus="true"
data-on-input="outputValueToConsole" data-on-valid="onValid.spinner" data-spinner-class="text-info"
data-max-length-helper="true" required />
</div>
</div>
<div class="form-group row">
<label for="lastName" class="col-2 col-form-label">Last Name</label>
<div class="col">
<input type="text" class="form-control bs-validate" name="lastName" id="lastName" minlength="2"
maxlength="40" data-hint="2 to 40 charcters required" data-alphanumeric-helper="true"
data-max-length-helper="true" required />
</div>
</div>
<div class="form-group row">
<label for="email" class="col-2 col-form-label">Email</label>
<div class="col">
<input type="email" class="form-control bs-validate" name="email" id="email"
data-email-domain-helper="true" required />
</div>
</div>
<div class="form-group row">
<label for="issue_date" class="col-2 col-form-label">Issue Date</label>
<div class="col">
<input type="date" class="form-control bs-validate" name="issue_date" id="issue_date" min="1900-01-01"
max="2099-12-31" required />
</div>
</div>
<div class="form-group row">
<label for="age" class="col-2 col-form-label">Age</label>
<div class="col">
<input type="number" class="form-control bs-validate" name="age" id="age" min="18" max="65" step="1"
data-hint="Enter a number between 18 to 65 in steps of 1" required />
</div>
</div>
<div class="form-group row">
<label for="education" class="col-2 col-form-label">Education</label>
<div class="col">
<select class="custom-select bs-validate" name="education" id="education" required>
<option></option>
<option value="1">High School</option>
<option value="2">College</option>
<option value="3">Graduate</option>
</select>
</div>
</div>
<div class="form-group row">
<legend class="col-form-label col-2">Terms</legend>
<div class="col col-form-label">
<div class="custom-control custom-checkbox">
<input class="custom-control-input bs-validate" type="checkbox" name="terms" id="terms" value="1"
required>
<label class="custom-control-label" for="terms">Agree</label>
</div>
</div>
</div>
<div class="form-group row">
<legend class="col-form-label col-2">Conditions</legend>
<div class="col col-form-label">
<div class="form-check form-check-inline">
<input class="form-check-input bs-validate" type="checkbox" name="conditions" id="conditions"
value="1" required>
<label class="form-check-label" for="conditions">Agree</label>
</div>
</div>
</div>
<div class="form-group row">
<legend class="col-form-label col-2">Tier</legend>
<div class="col col-form-label">
<div class="form-check">
<input class="form-check-input bs-validate" type="radio" name="tier" id="tier_1" value="1" required>
<label class="form-check-label" for="tier_1">
Gold
</label>
</div>
<div class="form-check">
<input class="form-check-input bs-validate" type="radio" name="tier" id="tier_2" value="2" required>
<label class="form-check-label" for="tier_2">
Platinum
</label>
</div>
</div>
</div>
<div class="form-group row">
<legend class="col-form-label col-2">Reward</legend>
<div class="col col-form-label">
<div class="custom-control custom-radio custom-control-inline">
<input class="custom-control-input bs-validate" type="radio" name="reward" id="reward_1" value="1"
required>
<label class="custom-control-label" for="reward_1">
Points
</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input class="custom-control-input bs-validate" type="radio" name="reward" id="reward_2" value="2"
required>
<label class="custom-control-label" for="reward_2">
Miles
</label>
</div>
</div>
</div>
<div class="form-group row">
<label for="group" class="col-2 col-form-label">Group</label>
<div class="col">
<div class="input-group">
<input type="text" class="form-control bs-validate" id="group" minlength="2" maxlength="40"
data-hint="2 to 40 charcters required" data-max-length-helper="true" data-on-valid="onValid.spinner"
required>
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button">Confirm</button>
</div>
</div>
</div>
</div>
<div class="from-group row mb-4">
<label for="comments" class="col-2 col-form-label">Comments</label>
<div class="col">
<textarea class="form-control bs-validate" name="comments" id="comments" rows="5"
data-on-input="outputValueToConsole" required></textarea>
</div>
</div>
<div class="form-row">
<div class="col-12 text-right">
<button type="submit" class="btn btn-primary">Create</button>
<button type="reset" class="btn btn-outline-danger">Reset</button>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</body>
</html>