forked from GDG-on-Campus-SKHU/24-25-WEB-Assignment-03
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproblem3.html
203 lines (187 loc) · 6.73 KB
/
problem3.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>문제 3</title>
<link rel="stylesheet" href="problem3.css" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,[email protected],100..700,0..1,-50..200"
/>
</head>
<body>
<div class="login" id="join">회원가입</div>
<hr class="hr_login" />
<div class="box" id="signupBox">
<img src="logo.jpeg" alt="사진" width="400px" height="155px" />
<hr
style="
width: 100%;
height: 1px;
background-color: rgb(191, 186, 186);
border: none;
margin-top: 0px;
"
/>
<form id="signupForm">
<div class="inputalign">
<span class="material-symbols-outlined">person</span>
<input
type="text"
id="user_id"
class="inputbox"
placeholder="아이디"
/>
</div>
<div class="inputalign">
<span class="material-symbols-outlined">lock</span>
<input
type="password"
id="password"
class="inputbox"
placeholder="비밀번호"
/>
</div>
<div class="inputalign">
<span class="material-symbols-outlined">mail</span>
<input type="text" id="email" class="inputbox" placeholder="이메일" />
</div>
<div class="inputalign">
<span class="material-symbols-outlined">person</span>
<input
type="text"
id="user_name"
class="inputbox"
placeholder="이름"
/>
</div>
<div class="inputalign">
<span class="material-symbols-outlined">badge</span>
<input
type="text"
id="birth"
class="inputbox"
placeholder="생년월일"
/>
</div>
<div class="inputalign">
<span class="material-symbols-outlined">call</span>
<input
type="text"
id="phone_number"
class="inputbox"
placeholder="전화번호"
/>
</div>
<div class="warning">
<div id="w1" style="display: none">
아이디는 3글자 이상이어야 합니다.
</div>
<div id="w2" style="display: none">
비밀번호는 6글자 이상이어야 합니다.
</div>
<div id="w3" style="display: none">
이메일 형식이 올바르지 않습니다.
</div>
<div id="w5" style="display: none">
생년월일 형식이 올바르지 않습니다.
</div>
<div id="w6" style="display: none">
전화번호는 숫자 11자여야 합니다.
</div>
<div id="w7" style="display: none">
모든 항목은 공백일 수 없습니다.
</div>
</div>
<button type="submit" class="buttonstyle1">회원가입</button>
<button type="button" class="buttonstyle2" id="button2">닫기</button>
</form>
<!-- 에러 메시지 출력 영역 -->
</div>
</div>
<script>
// 로그인 창 닫기 함수
function loginClose() {
const signupBox = document.getElementById("signupBox");
signupBox.style.display = "none"; // modal 숨기기
console.log("loginClose() 호출됨"); // 콘솔 출력
}
// 로그인 창 보이기 함수
function loginShow() {
const signupBox = document.getElementById("signupBox");
signupBox.style.display = "block"; // modal 나타내기
console.log("loginShow() 호출됨"); // 콘솔 출력
}
// 회원가입 영역 클릭 시 loginShow() 호출
document.getElementById("join").addEventListener("click", loginShow);
// 회원가입 유효성 검사
document
.getElementById("signupForm")
.addEventListener("submit", function (event) {
event.preventDefault(); // 폼 기본 제출 방지
const idValue = document.getElementById("user_id").value.trim();
const passwordValue = document
.getElementById("password")
.value.trim();
const emailValue = document.getElementById("email").value.trim();
const nameValue = document.getElementById("user_name").value.trim();
const birthdateValue = document.getElementById("birth").value.trim();
const phoneValue = document
.getElementById("phone_number")
.value.trim();
// 경고 문구 숨기기
document.getElementById("w1").style.display = "none";
document.getElementById("w2").style.display = "none";
document.getElementById("w3").style.display = "none";
document.getElementById("w5").style.display = "none";
document.getElementById("w6").style.display = "none";
document.getElementById("w7").style.display = "none";
let valid = true;
// 각 필드 공백 검사
if (
idValue.length === 0 ||
passwordValue.length === 0 ||
emailValue.length === 0 ||
nameValue.length === 0 ||
birthdateValue.length === 0 ||
phoneValue.length === 0
) {
document.getElementById("w7").style.display = "block";
valid = false;
}
// 아이디 검사
if (idValue.length < 3) {
document.getElementById("w1").style.display = "block";
valid = false;
}
// 비밀번호 검사
if (passwordValue.length < 6) {
document.getElementById("w2").style.display = "block";
valid = false;
}
// 이메일 형식 검사
if (!emailValue.match(/.+@.+\..+/)) {
document.getElementById("w3").style.display = "block";
valid = false;
}
// 생년월일 검사
if (!birthdateValue.match(/^\d{4}-\d{2}-\d{2}$/)) {
document.getElementById("w5").style.display = "block";
valid = false;
}
// 전화번호 검사
if (!phoneValue.match(/^\d{11}$/)) {
document.getElementById("w6").style.display = "block";
valid = false;
}
// 모든 입력이 유효할 경우 성공 페이지로 이동
if (valid) {
window.location.href = "success.html";
}
});
// 닫기 버튼 클릭 시 loginClose() 호출
document.getElementById("button2").addEventListener("click", loginClose);
</script>
</body>
</html>