-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
109 lines (107 loc) · 2.73 KB
/
index.html
File metadata and controls
109 lines (107 loc) · 2.73 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>qFormValidate Test</title>
<style>
body {
font-family: sans-serif;
max-width: 400px;
margin: 2rem auto;
}
textarea.error,
select.error,
input:not(input[type="checkbox"], input[type="radio"]).error {
border: 1px solid red;
}
ol, li {
list-style: none;
margin: 0;
padding: 0;
}
label {
display: block;
margin-top: 1rem;
}
.inline-error {
display: block;
color: red;
font-size: 10px;
padding: 5px;
}
input, select, textarea {
width: 100%;
}
</style>
</head>
<body>
<h1>qFormValidate Demo</h1>
<form id="myForm">
<ol>
<li>
<label>Not required</label>
<input type="email" name="email">
</li>
<li>
<label>Test</label>
<select name="select" data-error-msg="ermhgerd!" required>
<option></option>
<option>Stewart</option>
<option>Claire</option>
<option>Dave</option>
<option>Ian</option>
</select>
</li>
<li>
<label>Test</label>
<select name="select" data-error-msg="ermhgerd!" required multiple>
<option></option>
<option>Stewart</option>
<option>Claire</option>
<option>Dave</option>
<option>Ian</option>
</select>
</li>
<li>
<label>Email</label>
<input type="email" name="email" required>
</li>
<li>
<label>Website</label>
<input type="url" name="url">
</li>
<li>
<label>File not required</label>
<input type="file" name="file">
</li>
<li>
<label>File required</label>
<input type="file" name="file2" required>
</li>
<li>
<label>Phone</label>
<input type="tel" name="phone" id="phone" required>
</li>
<li>
<label>Password</label>
<input type="password" name="password" data-min-length="6" required>
</li>
<li>
<input type="checkbox" name="checkbox" required data-error-msg="You must agree to this thing.">
<label>I agree to something</label>
</li>
</ol>
<button type="submit">Submit</button>
</form>
<script type="module">
import { qFormValidate } from './dist/qformvalidate.esm.js';
const form = document.getElementById('myForm');
qFormValidate(form, {
onBeforeValidate: () => console.log('Validating...'),
onAfterValidate: () => console.log('Done validating!'),
onFieldSuccess: (field) => console.log(field, 'VALID')
});
</script>
</body>
</html>