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(); -};