Repository navigation
Expand file tree
/
Copy pathesm.html
More file actions
69 lines (65 loc) · 1.71 KB
/
Copy pathesm.html
File metadata and controls
69 lines (65 loc) · 1.71 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>form-required-checkboxes via esm.sh</title>
<link rel="stylesheet" href="./styles.css" />
</head>
<body>
<h1>esm.sh CDN sanity check</h1>
<p>
This page loads the component class from <code>esm.sh</code> and
registers it manually.
</p>
<form>
<form-required-checkboxes required="2-3">
<fieldset>
<legend>Select 2 or 3 toppings</legend>
<label
><input
type="checkbox"
name="toppings"
value="pepperoni"
/>
Pepperoni</label
>
<label
><input
type="checkbox"
name="toppings"
value="mushroom"
/>
Mushroom</label
>
<label
><input type="checkbox" name="toppings" value="olive" />
Olive</label
>
<label
><input type="checkbox" name="toppings" value="onion" />
Onion</label
>
</fieldset>
</form-required-checkboxes>
<button type="submit">Submit</button>
<button type="reset">Reset</button>
</form>
<script type="module">
import { FormRequiredCheckboxesElement } from 'https://esm.sh/@aarongustafson/form-required-checkboxes@3.2.4/form-required-checkboxes.js?bundle&target=es2022';
if (!customElements.get('form-required-checkboxes')) {
customElements.define(
'form-required-checkboxes',
FormRequiredCheckboxesElement,
);
}
// Prevent actual form submission for demo purposes
document.body.addEventListener('submit', (e) => {
if (e.target.checkValidity()) {
e.preventDefault();
alert('Form is valid and would have been submitted!');
}
});
</script>
</body>
</html>