Skip to content

Commit de88b5d

Browse files
committed
Feat: 회원가입 페이지 비밀번호 visible조절 기능 추가
1 parent 4557f08 commit de88b5d

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

signup.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@
3636
<label for="password">비밀번호</label>
3737
<div class="input-wrapper">
3838
<input id="password" type="password" name="password" />
39-
<img src="images/eye-close.png" alt="보기 아이콘" />
39+
<img id="viewIcon" src="images/eye-close.png" alt="보기 아이콘" />
4040
<p id="passwordError" style="display: none; color: red"></p>
4141
</div>
4242
</div>
4343
<div class="form-group">
4444
<label for="passwordCheck">비밀번호 확인</label>
4545
<div class="input-wrapper">
4646
<input id="passwordCheck" type="text" name="text" />
47-
<img src="images/eye-open.png" alt="보기 아이콘" />
47+
<img id="viewIcon2" src="images/eye-open.png" alt="보기 아이콘" />
4848
<p id="passwordCheckError" style="display: none; color: red"></p>
4949
</div>
5050
</div>

signup.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const $passwordError = document.querySelector('#passwordError');
77
const $passwordCheck = document.querySelector('#passwordCheck');
88
const $passwordCheckError = document.querySelector('#passwordCheckError');
99
const $signupBtn = document.querySelector('#signupBtn');
10+
const $viewIcon = document.querySelector('#viewIcon');
11+
const $viewIcon2 = document.querySelector('#viewIcon2');
1012
let idCheck = false;
1113
let passwordCheck = false;
1214
let nicknameCheck = false;
@@ -91,7 +93,25 @@ function handleFocusOutPassWordCheck() {
9193
btnCheck();
9294
}
9395

96+
function handlePassWordView() {
97+
const isPassWordVisible = $password.type === 'text';
98+
$password.type = isPassWordVisible ? 'password' : 'text';
99+
$viewIcon.src = isPassWordVisible
100+
? 'images/eye-close.png'
101+
: 'images/eye-open.png';
102+
}
103+
104+
function handlePassWordView2() {
105+
const isPassWordVisible = $passwordCheck.type === 'text';
106+
$passwordCheck.type = isPassWordVisible ? 'password' : 'text';
107+
$viewIcon2.src = isPassWordVisible
108+
? 'images/eye-close.png'
109+
: 'images/eye-open.png';
110+
}
111+
94112
$userId.addEventListener('focusout', handleFocustOutId);
95113
$password.addEventListener('focusout', handleFocutOutPassWord);
96114
$nickName.addEventListener('focusout', handleFocusOutNickName);
97115
$passwordCheck.addEventListener('focusout', handleFocusOutPassWordCheck);
116+
$viewIcon.addEventListener('click', handlePassWordView);
117+
$viewIcon2.addEventListener('click', handlePassWordView2);

0 commit comments

Comments
 (0)