forked from goitacademy/nodejs-homework-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
31 lines (31 loc) · 1.06 KB
/
index.html
File metadata and controls
31 lines (31 loc) · 1.06 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<form id="form-add-contact" enctype="multipart/form-data">
<div><input type="text" name="name" /></div>
<div><input type="number" name="phone" /></div>
<div><input type="file" name="avatar" /></div>
<button type="submit">Push the limit</button>
</form>
<script>
const formRef = document.getElementById("form-add-contact");
formRef.addEventListener("submit", function (e) {
e.preventDefault();
const { name, phone, avatar } = this.elements;
// console.log(name.value);
// console.log(phone.value);
// console.log(avatar.files[0]);
const data = new FormData();
data.append("name", name.value);
data.append("phone", phone.value);
data.append("avatar", avatar.files[0]);
});
</script>
</body>
</html>