-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignUp.js
More file actions
174 lines (159 loc) · 5.65 KB
/
signUp.js
File metadata and controls
174 lines (159 loc) · 5.65 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
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
//아이디
let elInputUsername = document.querySelector('#email');
let elSuccessMessage = document.querySelector('.success-message');
let elFailureMessage = document.querySelector('.failure-message');
//비밀번호
let elInputPassword = document.querySelector('#password');
let elStrongPasswordMessage = document.querySelector('.strongPassword-message');
function strongPassword(str) {
return /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{6,20}$/.test(str);
}
elInputUsername.onkeyup = function () {
// 값을 입력한 경우
if (elInputUsername.value.length !== 0) {
if(elInputUsername.value.indexOf('@') == -1) {
elSuccessMessage.classList.add('hide');
elFailureMessage.classList.remove('hide');
}
// 조건을 모두 만족할 경우
else if(elInputUsername.value!==0 || elInputUsername.value.indexOf('@') == -1) {
elSuccessMessage.classList.remove('hide'); // 사용할 수 있는 아이디입니다
elFailureMessage.classList.add('hide'); // 실패 메시지가 가려져야 함
}
}
// 값을 입력하지 않은 경우 (지웠을 때)
// 모든 메시지를 가린다.
else {
elSuccessMessage.classList.add('hide');
elFailureMessage.classList.add('hide');
}
}
elInputPassword.onkeyup = function () {
// console.log(elInputPassword.value);
// 값을 입력한 경우
if (elInputPassword.value.length !== 0) {
if(strongPassword(elInputPassword.value)) {
elStrongPasswordMessage.classList.add('hide'); // 실패 메시지가 가려져야 함
}
else {
elStrongPasswordMessage.classList.remove('hide'); // 실패 메시지가 보여야 함
}
}
// 값을 입력하지 않은 경우 (지웠을 때)
// 모든 메시지를 가린다.
else {
elStrongPasswordMessage.classList.add('hide');
}
}
function change_btn(gender){
var btns = document.querySelectorAll(".genders")
btns.forEach(function(btn, i) {
if(gender.currentTarget == btn){
btn.classList.add("active");
}
else{
btn.classList.remove("active");
}
});
console.log(gender.currentTarget);
}
const birthYearEl = document.querySelector('#birth-year')
isYearOptionExisted = false;
birthYearEl.addEventListener('focus', function() {
if(!isYearOptionExisted) {
isYearOptionExisted = true
for(var i = 1950; i<=2024; i++){
const YearOption = document.createElement('option')
YearOption.setAttribute('value', i)
YearOption.innerText = i
this.appendChild(YearOption);
}
}
});
const birthMonthEl = document.querySelector('#birth-month')
isMonthOptionExisted = false;
birthMonthEl.addEventListener('focus', function() {
if(!isMonthOptionExisted) {
isMonthOptionExisted = true
for(var i = 1; i<=12; i++){
const MonthOption = document.createElement('option')
MonthOption.setAttribute('value', i)
MonthOption.innerText = i
this.appendChild(MonthOption);
}
}
});
const birthDayEl = document.querySelector('#birth-day')
isDayOptionExisted = false;
birthDayEl.addEventListener('focus', function() {
if(!isDayOptionExisted) {
isDayOptionExisted = true
for(var i = 1; i<=31; i++){
const DayOption = document.createElement('option')
DayOption.setAttribute('value', i)
DayOption.innerText = i
this.appendChild(DayOption);
}
}
});
function updateBirthDate() {
var year = document.getElementById("birth-year").value;
var month = document.getElementById("birth-month").value;
var day = document.getElementById("birth-day").value;
document.getElementById("completeBirthDate").value = year + '-' + month + '-' + day;
}
document.getElementById("birth-year").addEventListener("change", updateBirthDate);
document.getElementById("birth-month").addEventListener("change", updateBirthDate);
document.getElementById("birth-day").addEventListener("change", updateBirthDate);
document.addEventListener('DOMContentLoaded', function() {
const yearSelect = document.getElementById('birth-year');
const monthSelect = document.getElementById('birth-month');
const daySelect = document.getElementById('birth-day');
const completeBirthDateInput = document.getElementById('completeBirthDate');
function updateCompleteBirthDate() {
const year = yearSelect.value;
const month = monthSelect.value.padStart(2, '0'); // 한자리 숫자 앞에 0 붙이기
const day = daySelect.value.padStart(2, '0'); // 한자리 숫자 앞에 0 붙이기
if (year && month && day) {
completeBirthDateInput.value = `${year}-${month}-${day}`;
} else {
completeBirthDateInput.value = ''; // 모든 필드가 선택되지 않았다면 입력값을 비웁니다.
}
}
// 각 셀렉트 박스에 대해 change 이벤트 리스너 등록
yearSelect.addEventListener('change', updateCompleteBirthDate);
monthSelect.addEventListener('change', updateCompleteBirthDate);
daySelect.addEventListener('change', updateCompleteBirthDate);
// 초기화를 위해 함수를 한 번 호출
updateCompleteBirthDate();
});
function Click(){
var agree_data;
if(document.getElementById("agree").checked){
agree_data="동의";
}
else if(document.getElementById("disagree").checked){
agree_data="비동의";
}
else{
alert("동의 버튼을 눌러주세요.");
}
if(agree_data.length!=0){
location.replace("search_list.php?id="+agree_data);
}
}
function Click2(){
var agree_data2;
if(document.getElementById("agree2").checked){
agree_data2="동의";
}
else if(document.getElementById("disagree2").checked){
agree_data2="비동의";
}
else{
alert("동의 버튼을 눌러주세요.");
}
if(agree_data2.length!=0){
location.replace("search_list.php?id="+agree_data2);
}
}