From 8605ced21b55039e7f82c541ac364c4553be2405 Mon Sep 17 00:00:00 2001 From: Daewony Date: Fri, 11 Oct 2024 16:01:44 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=99=94=EC=82=B4=ED=91=9C=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=EB=A1=9C,=20=EC=BD=9C=EB=B0=B1=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B8=ED=95=9C=20=ED=98=B8=EC=9D=B4=EC=8A=A4=ED=8C=85?= =?UTF-8?q?=EC=9D=B4=20=EC=95=88=EB=90=98=EC=96=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/form-validation.js | 10 ++++++---- common/js/modal.js | 24 ++++++++++++------------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/common/js/form-validation.js b/common/js/form-validation.js index 8dff56f4..ce51ac11 100644 --- a/common/js/form-validation.js +++ b/common/js/form-validation.js @@ -10,7 +10,6 @@ const passwordConfirm = document.getElementById('password-confirm'); const formButton = document.getElementById('form-button'); // -----폼 제출 시 이벤트 처리----- -form.addEventListener('submit', handleFormSubmit); const handleFormSubmit = (e) => { e.preventDefault(); @@ -32,13 +31,16 @@ const handleFormSubmit = (e) => { } }; +form.addEventListener('submit', handleFormSubmit); + // -----입력 시 제출 버튼 상태 업데이트----- -form.addEventListener('input', updateSubmitButtonState); const updateSubmitButtonState = () => { setSubmitButtonState(); }; +form.addEventListener('input', updateSubmitButtonState); + // 제출 버튼 활성화 상태 설정 함수 const setSubmitButtonState = () => { const currentPage = window.location.pathname; @@ -107,13 +109,13 @@ const isUserExist = (email, password) => { }; // -----포커스 아웃 시 유효성 검사----- -form.addEventListener('focusout', handleFocusOut); - const handleFocusOut = (e) => { const validateElementId = e.target.id; validateForm(validateElementId); }; +form.addEventListener('focusout', handleFocusOut); + const validateForm = (validateElementId) => { const validationHandlers = { email: () => validateEmail(), diff --git a/common/js/modal.js b/common/js/modal.js index 72e9b680..ca4e0e45 100644 --- a/common/js/modal.js +++ b/common/js/modal.js @@ -1,17 +1,21 @@ const modal = document.getElementById('error-message-modal'); const closeModalButton = document.querySelector('.close-modal-button'); -// 모달 닫기 버튼 이벤트 -closeModalButton.addEventListener('click', () => { - closeModal(); -}); +export const closeModal = () => { + modal.close(); +}; + +// -----모달 닫기 버튼 이벤트----- +closeModalButton.addEventListener('click', closeModal); + +// -----모달 외부 클릭 시 닫기----- -// 모달 외부 클릭 시 닫기 -modal.addEventListener('click', (e) => { - if (isModalOutSideClicked) { +const handleCloseModal = (e) => { + if (isModalOutSideClicked(e)) { closeModal(); } -}); +}; +modal.addEventListener('click', handleCloseModal); // 모달 외부 클릭 했는지 확인 const isModalOutSideClicked = (e) => { @@ -28,7 +32,3 @@ const isModalOutSideClicked = (e) => { export const showModal = () => { modal.showModal(); }; - -export const closeModal = () => { - modal.close(); -};