새 계정 만들기
function doJoin() { const name = document.getElementById('joinName').value.trim(); const email = document.getElementById('joinEmail').value.trim(); const phone = document.getElementById('joinPhone').value.trim(); const pw = document.getElementById('joinPw').value; const pw2 = document.getElementById('joinPw2').value; const zipcode = document.getElementById('joinZipcode').value.trim(); const addr = document.getElementById('joinAddr').value.trim(); const addrDetail = document.getElementById('joinAddrDetail').value.trim(); const errEl = document.getElementById('joinError'); errEl.style.display = 'none'; const show = msg => { errEl.textContent = msg; errEl.style.display = 'block'; }; if (!name) return show('이름을 입력해주세요.'); if (!email) return show('이메일을 입력해주세요.'); if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) return show('올바른 이메일 형식으로 입력하세요.'); if (pw.length < 6) return show('비밀번호는 6자 이상이어야 합니다.'); if (pw !== pw2) return show('비밀번호가 일치하지 않습니다.'); if (!document.getElementById('agree1').checked || !document.getElementById('agree2').checked) return show('필수 약관에 동의해주세요.'); const result = Members.register({ name, email, password: pw, phone, zipcode, addr, addrDetail }); if (!result.ok) return show(result.msg); Members.login(email, pw); alert('🎉 ' + name + '님, 회원가입이 완료되었습니다!\n예고을 한과 가족이 되신 것을 환영합니다.'); location.href = 'mypage.html'; } location.href = 'mypage.html'; }