-
Notifications
You must be signed in to change notification settings - Fork 20
[김교연] Sprint4 #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "Basic-\uAE40\uAD50\uC5F0-sprint4"
[김교연] Sprint4 #75
Changes from all commits
93958c4
bfae84a
f1c3921
71e8514
aded473
dda0a6b
adbca31
d137900
7ae8ca3
ec58732
562328e
213d5b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| document.addEventListener("DOMContentLoaded", function () { | ||
| const emailInput = document.getElementById("email"); | ||
| const emailInputBorder = document.getElementById("email_input"); | ||
| const emailError = document.getElementById("email_error"); | ||
| const passwordInput = document.getElementById("password"); | ||
| const passwordInputBorder = document.getElementById("password_input"); | ||
| const passwordError = document.getElementById("password_error"); | ||
| const loginButton = document.querySelector(".btn_login2"); | ||
| const togglePasswordIcon = document.querySelector(".input_icon"); | ||
|
|
||
| /* 비밀번호 보이기 */ | ||
| togglePasswordIcon.addEventListener("click", function () { | ||
| if (passwordInput.type === "password") { | ||
| passwordInput.type = "text"; // 비밀번호 보이기 | ||
| togglePasswordIcon.src = "../img/login/btn_hidepw.svg"; | ||
| } else { | ||
| passwordInput.type = "password"; // 비밀번호 가리기 | ||
| togglePasswordIcon.src = "../img/login/btn_showpw.svg"; | ||
| } | ||
| }); | ||
|
|
||
| /* 이메일 유효성 */ | ||
| function validateEmail(email) { | ||
| const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; | ||
| return emailRegex.test(email); | ||
| } | ||
|
Comment on lines
+23
to
+26
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 크으 ~ 순수 함수로 잘 작성된 함수입니다 👍👍일관된 타입, 일관된 반환값, 외부의 상태를 변경하지 않는 깔끔한 함수입니다 👍
|
||
|
|
||
| /* 비밀번호 유효성 */ | ||
| function validateInputs() { | ||
| const isEmailValid = emailInput.value && validateEmail(emailInput.value); | ||
| const isPasswordValid = | ||
| passwordInput.value && passwordInput.value.length >= 8; | ||
| const isFormValid = isEmailValid && isPasswordValid; | ||
|
Comment on lines
+30
to
+33
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 별칭(
|
||
|
|
||
| if (isFormValid) { | ||
| loginButton.classList.add("active"); | ||
| loginButton.disabled = false; | ||
| } else { | ||
| loginButton.classList.remove("active"); | ||
| loginButton.disabled = true; | ||
| } | ||
| } | ||
|
|
||
| /* 이메일 에러메세지 */ | ||
| function checkEmail() { | ||
| if (!emailInput.value) { | ||
| emailError.textContent = "이메일을 입력해주세요."; | ||
| emailError.style.display = "block"; | ||
| emailInputBorder.classList.add("error-border"); | ||
| } else if (!validateEmail(emailInput.value)) { | ||
| emailError.textContent = "잘못된 이메일 형식입니다."; | ||
| emailError.style.display = "block"; | ||
| emailInputBorder.classList.add("error-border"); // input 오류 | ||
| } else { | ||
| emailError.style.display = "none"; | ||
| emailInputBorder.classList.remove("error-border"); // input 오류 제거 | ||
| emailInputBorder.classList.add("success-border"); | ||
| } | ||
| validateInputs(); | ||
| } | ||
|
|
||
| /* 비밀번호 에러메세지 */ | ||
| function checkPassword() { | ||
| if (passwordInput.value.length < 8) { | ||
| passwordError.textContent = "비밀번호를 8자 이상 입력해주세요."; | ||
| passwordError.style.display = "block"; | ||
| passwordInputBorder.classList.add("error-border"); | ||
| } else { | ||
| passwordError.style.display = "none"; | ||
| passwordInputBorder.classList.remove("error-border"); | ||
| passwordInputBorder.classList.add("success-border"); | ||
| } | ||
| validateInputs(); | ||
| } | ||
|
|
||
| emailInput.addEventListener("input", checkEmail); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (참고/선택) 이벤트 객체를 활용해볼 수도 있습니다 !<input id="text" />document.getElementById("text")
.addEventListener("input", (e) => {
console.log('$$ e', e.target.value);
e.target.style = "background-color: red"
});이렇게 하면 부가적인 전역 변수 선언을 줄이며 코드를 작성 하는 데에 도움이 될 수 있을거예요 ! 😊 |
||
| passwordInput.addEventListener("input", checkPassword); | ||
|
|
||
| /* 로그인 버튼 활성화 */ | ||
| loginButton.addEventListener("click", function (event) { | ||
| if (!loginButton.classList.contains("active")) { | ||
| event.preventDefault(); // 비활성화 상태 클릭 방지 | ||
| } else { | ||
| window.location.href = "/items"; | ||
| } | ||
| }); | ||
|
|
||
| validateInputs(); // 페이지 로드 시 초기 상태 체크 | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| href="https://cdn.jsdelivr.net/npm/[email protected]/reset.min.css" | ||
| /> | ||
| <link rel="stylesheet" href="../Login/login.css" /> | ||
| <link rel="stylesheet" href="./signup.css" /> | ||
| </head> | ||
|
|
||
| <body> | ||
|
|
@@ -18,46 +19,56 @@ | |
| </div> | ||
| <div class="login_content"> | ||
| <h3>이메일</h3> | ||
| <div class="input_wrapper"> | ||
| <div class="input_wrapper" id="email_input"> | ||
| <input | ||
| id="email" | ||
| name="email" | ||
| placeholder="이메일을 입력해주세요." | ||
| /> | ||
| </div> | ||
| <p id="email_error" class="error"></p> | ||
| <h3>닉네임</h3> | ||
| <div class="input_wrapper"> | ||
| <input | ||
| id="email" | ||
| name="email" | ||
| placeholder="닉네임을 입력해주세요." | ||
| /> | ||
| <div class="input_wrapper" id="name_input"> | ||
| <input id="name" name="name" placeholder="닉네임을 입력해주세요." /> | ||
| </div> | ||
| <p id="name_error" class="error"></p> | ||
| <h3>비밀번호</h3> | ||
| <div class="input_wrapper"> | ||
| <div class="input_wrapper" id="password_input"> | ||
| <input | ||
| id="passwd" | ||
| name="passwd" | ||
| name="password" | ||
| type="password" | ||
| minlength="8" | ||
| maxlength="20" | ||
| placeholder="비밀번호를 입력해주세요." | ||
| /> | ||
| <img src="../img/login/btn_showpw.svg" class="input_icon" /> | ||
| <img | ||
| id="pwicon" | ||
| src="../img/login/btn_showpw.svg" | ||
| class="input_icon" | ||
| /> | ||
| </div> | ||
| <p id="passwd_error" class="error"></p> | ||
| <h3>비밀번호 확인</h3> | ||
| <div class="input_wrapper"> | ||
| <div class="input_wrapper" id="checkpw_input"> | ||
| <input | ||
| id="passwd" | ||
| name="passwd" | ||
| id="checkPw" | ||
| name="checkPassword" | ||
| type="password" | ||
| minlength="8" | ||
| maxlength="20" | ||
| placeholder="비밀번호를 다시 입력해주세요." | ||
| /> | ||
| <img src="../img/login/btn_showpw.svg" class="input_icon" /> | ||
| <img | ||
| id="checkpwicon" | ||
| src="../img/login/btn_showpw.svg" | ||
| class="input_icon" | ||
| /> | ||
| </div> | ||
| <a href="/items"><button class="btn_login2">회원가입</button></a> | ||
| <p id="checkPasswd_error" class="error"></p> | ||
| <a href="/items" | ||
| ><button class="btn_signup" id="btn_signup">회원가입</button></a | ||
| > | ||
| <div class="sns_login"> | ||
| <div class="sns_login_content"> | ||
| <span class="sns_login_text">간편 로그인 하기</span> | ||
|
|
@@ -83,5 +94,6 @@ <h3>비밀번호 확인</h3> | |
| </div> | ||
| </div> | ||
| </main> | ||
| <script src="signup.js"></script> | ||
| </body> | ||
| </html> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿굿 이렇게 하면 로드가 완료된 후 자바스크립트가 실행 되는 것을 보장받을 수 있겠네요 👍👍