-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsignup.js
More file actions
70 lines (60 loc) · 2.52 KB
/
signup.js
File metadata and controls
70 lines (60 loc) · 2.52 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
document.addEventListener("DOMContentLoaded", function () {
function generateOptions(selectElement, start, end) {
for (let i = start; i <= end; i++) {
var option = document.createElement("option");
option.value = i;
option.text = i;
selectElement.appendChild(option);
}
}
var birthYearSelect = document.getElementById("birthYear");
generateOptions(birthYearSelect, 1950, 2024);
var birthMonthSelect = document.getElementById("birthMonth");
generateOptions(birthMonthSelect, 1, 12);
var birthDaySelect = document.getElementById("birthDay");
generateOptions(birthDaySelect, 1, 31);
var signUpForm = document.querySelector("form");
if (signUpForm) {
signUpForm.addEventListener("submit", handleSignUp);
}
function handleSignUp(event) {
event.preventDefault();
var emailInput = document.querySelector(".emailInput");
var passwordInput = document.querySelector(".passwordInput");
var checkPasswordInput = document.querySelector(".checkPasswordInput");
var nameInput = document.querySelector(".nameInput");
var genderInput = document.querySelector(".genderInput");
var birthYearInput = document.querySelector("#birthYear");
var birthMonthInput = document.querySelector("#birthMonth");
var birthDayInput = document.querySelector("#birthDay");
var firstNumInput = document.querySelector("#firstNum");
var middleNumInput = document.querySelector("#middleNum");
var lastNumInput = document.querySelector("#lastNum");
var monthValue = String(birthMonthInput.value).padStart(2, '0');
var dayValue = String(birthDayInput.value).padStart(2, '0');
if (passwordInput.value !== checkPasswordInput.value) {
alert("비밀번호를 확인해주세요.");
return;
}
var formData = {
email: emailInput.value,
password: passwordInput.value,
name: nameInput.value,
gender: genderInput.value,
birth: `${birthYearInput.value}-${monthValue}-${dayValue}`,
phoneNumber: `${firstNumInput.value}-${middleNumInput.value}-${lastNumInput.value}`,
};
fetch("https://qquickqqueue.store/api/signup", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(formData),
})
.then((response) => response.json())
.then((data) => {
alert(data.message);
window.location.href = "login.html";
});
}
});