-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.html
253 lines (247 loc) · 8.54 KB
/
signup.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>회원가입 페이지</title>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous"
/>
<style>
.signin-link {
margin-right: 20px;
}
.signin-link,
.signup-link {
color: azure;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-secondary">
<a class="navbar-brand" href="#">회원가입 페이지</a>
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="signin-link" href="https://hoooooony.github.io/signup.html"
>회원가입</a
>
</li>
<li class="nav-item">
<a class="signup-link" href="https://hoooooony.github.io/signin.html"
>로그인</a
>
</li>
</ul>
</nav>
<div class="container mt-5">
<h1>회원가입</h1>
<form onsubmit="return false;">
<div class="form-group">
<label for="id">ID</label>
<input
type="text"
class="form-control"
id="id"
placeholder="ID를 입력하세요"
onblur="emailCheck()"
/>
<div id="email-check">###@##.com형식을 지켜주세요</div>
</div>
<div class="form-group">
<label for="pw">Password</label>
<input
type="password"
class="form-control"
id="pw"
placeholder="비밀번호를 입력하세요"
/>
</div>
<div class="form-group">
<label for="pw-check">Password 확인</label>
<input
type="password"
class="form-control"
id="pw-check"
placeholder="비밀번호를 다시 입력하세요"
onblur="pwCheck()"
/>
<div id="pw-check-box">동일한 비밀번호를 작성해주세요.</div>
</div>
<div class="form-group">
<label for="student-number">학번</label>
<input
type="number"
class="form-control"
id="student-number"
placeholder="학번을 입력하세요"
onchange="selectOption()"
/>
<div id="student-number-check">학번은 10자리입니다.</div>
</div>
<div class="form-group">
<label for="maior">전공</label>
<select class="form-control" id="maior">
<option value="0">전공을 선택하세요</option>
<option value="1">기계공학부</option>
<option value="2">산업경영학부</option>
<option value="3">컴퓨터공학부</option>
<option value="4">메카트로닉스공학부</option>
<option value="5">고용서비스정책학과</option>
<option value="6">디자인공학부</option>
<option value="7">에너지신소재화학공학부</option>
<option value="8">전기전자통신공학부</option>
<option value="9">건축공학부</option>
</select>
</div>
<div class="form-group">
<label for="phone-number">전화번호</label>
<input
type="text"
class="form-control"
id="phone-number"
placeholder="전화번호를 입력하세요"
onchange="changePhoneNumber()"
/>
<div id="Phone-number-check">숫자만 입력하시오</div>
</div>
<button type="submit" class="btn btn-primary">회원가입</button>
<button type="reset" class="btn btn-dark">취소</button>
</form>
</div>
<script
src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"
></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"
></script>
<script>
const $emailcheckbox = document.getElementById("email-check");
const $pwCheckBox = document.getElementById("pw-check-box");
const $studentId = document.getElementById("student-number");
const $maiorSelect = document.getElementById("maior");
const $studentNumberCheck = document.getElementById(
"student-number-check"
);
let email =
/^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*.[a-zA-Z]{2,3}$/i;
function emailCheck() {
const emailInput = document.getElementById("id");
if (emailInput.value.match(email)) {
$emailcheckbox.innerText = "올바른 이메일 입력";
$emailcheckbox.style.color = "black";
} else {
$emailcheckbox.innerText = "틀린 이메일 형식";
$emailcheckbox.style.color = "red";
}
}
function pwCheck() {
const pwInput = document.getElementById("pw");
const pwCheckInput = document.getElementById("pw-check");
console.log(pwInput.value, pwCheckInput.value);
if (pwInput.value === pwCheckInput.value) {
$pwCheckBox.innerText = "동일 비밀번호 입력";
$pwCheckBox.style.color = "black";
} else {
$pwCheckBox.innerText = "다른 비밀번호 입력";
$pwCheckBox.style.color = "red";
}
}
function selectOption() {
let studentIdText = $studentId.value.toString();
if (checkStudentId(studentIdText)) {
let maiorNumber = studentIdText.substr(5, 2);
switch (maiorNumber) {
case "20":
$maiorSelect.value = "1";
break;
case "80":
$maiorSelect.value = "2";
break;
case "35":
case "36":
console.log(maiorNumber);
$maiorSelect.value = "3";
break;
case "40":
$maiorSelect.value = "4";
break;
case "85":
$maiorSelect.value = "5";
break;
case "51":
$maiorSelect.value = "6";
break;
case "74":
$maiorSelect.value = "7";
break;
case "61":
$maiorSelect.value = "8";
break;
case "72":
$maiorSelect.value = "9";
break;
default:
$maiorSelect.value = "0";
}
}
}
function checkStudentId(studentIdText) {
if (studentIdText.length != 10) {
$studentNumberCheck.innerText = "올바르지 못한 형식";
return false;
} else {
$studentNumberCheck.innerText = "올바른 형식";
return true;
}
}
function changePhoneNumber() {
const $PhoneNumber = document.getElementById("phone-number");
let check = /\d/;
const $PhoneNumberCheck = document.getElementById("Phone-number-check");
if ($PhoneNumber.value.match(check)) {
$PhoneNumberCheck.innerText = "올바른 형식";
$PhoneNumberCheck.style.color = "black";
if ($PhoneNumber.value.substr(0, 3) == "010") {
$PhoneNumber.value = `${$PhoneNumber.value.substr(
0,
3
)} - ${$PhoneNumber.value.substr(
3,
4
)} - ${$PhoneNumber.value.substr(7, 4)}`;
} else if ($PhoneNumber.value.substr(0, 2) == "02") {
$PhoneNumber.value = `${$PhoneNumber.value.substr(
0,
2
)} - ${$PhoneNumber.value.substr(
2,
4
)} - ${$PhoneNumber.value.substr(6, 4)}`;
} else {
$PhoneNumber.value = `${$PhoneNumber.value.substr(
0,
3
)} - ${$PhoneNumber.value.substr(
3,
3
)} - ${$PhoneNumber.value.substr(6, 4)}`;
}
} else {
$PhoneNumberCheck.innerText = "잘못된 형식 숫자로 입력하시오.";
$PhoneNumberCheck.style.color = "red";
}
}
</script>
</body>
</html>