-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvanilla.html
45 lines (35 loc) · 1.13 KB
/
vanilla.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
<html>
<head>
<title>Autofill without web components</title>
</head>
<style>
label,
button {
display: block;
margin-top: 1rem;
}
</style>
<script>
const init = () => {
document.getElementById('autofill-form').addEventListener('submit', (e) => {
e.preventDefault();
const data = new FormData(e.target);
const value = Object.fromEntries(data.entries());
localStorage.setItem('data', JSON.stringify(value));
});
}
</script>
<body onload="init()">
<form id="autofill-form">
<label for="firstName">First Name:</label>
<input name="firstName" type="text" autocomplete="given-name">
<label for="lastName">Last Name:</label>
<input name="lastName" type="text" autocomplete="family-name">
<label for="username">Username:</label>
<input name="username" type="username" autocomplete="username">
<label for="password">Password:</label>
<input name="password" type="password" autocomplete="password">
<button id="save-details">Save details</button>
</form>
</body>
</html>