From 5e1ab94a81d5bd3e941900b0745d62183bb4ab27 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 28 Jan 2026 20:18:37 +1100 Subject: [PATCH] Loginv2 --- index.html | 35 ++++++----------------------------- script.js | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/index.html b/index.html index a909f5e..427357d 100644 --- a/index.html +++ b/index.html @@ -34,6 +34,11 @@ + + Forgot Password? -
- Or continue with -
- -
- - -
+ diff --git a/script.js b/script.js index 5259c60..fb5c0ee 100644 --- a/script.js +++ b/script.js @@ -2,6 +2,8 @@ document.addEventListener('DOMContentLoaded', () => { const loginForm = document.querySelector('.login-form'); const emailInput = document.getElementById('email'); const passwordInput = document.getElementById('password'); + const confirmPasswordInput = document.getElementById('confirm-password'); + const confirmPasswordGroup = document.getElementById('confirm-password-group'); const submitBtn = document.querySelector('.btn-primary'); const btnText = submitBtn.querySelector('span'); const helperText = document.querySelector('.signup-link'); @@ -26,11 +28,15 @@ document.addEventListener('DOMContentLoaded', () => { subtitle.innerText = 'Enter your details below'; btnText.innerText = 'Sign In'; helperText.innerHTML = 'Don\'t have an account? Create One'; + confirmPasswordGroup.classList.add('hidden'); + confirmPasswordInput.required = false; } else { title.innerText = 'Create Account'; subtitle.innerText = 'Start your journey with us'; btnText.innerText = 'Sign Up'; helperText.innerHTML = 'Already have an account? Sign In'; + confirmPasswordGroup.classList.remove('hidden'); + confirmPasswordInput.required = true; } // Re-attach listener to the new link element @@ -77,6 +83,7 @@ document.addEventListener('DOMContentLoaded', () => { const email = emailInput.value.trim(); const password = passwordInput.value.trim(); + const confirmPassword = confirmPasswordInput.value.trim(); const timestamp = new Date().toISOString(); // Get existing users @@ -97,12 +104,18 @@ document.addEventListener('DOMContentLoaded', () => { } else { // --- SIGNUP LOGIC --- - // Check if user already exists + // 1. Check if user already exists if (existingUsers.some(u => u.email === email)) { showFeedback(false, 'User exists'); return; } + // 2. Validate Password Match + if (password !== confirmPassword) { + showFeedback(false, 'Passwords do not match'); + return; + } + const newUser = { email, password, joinedAt: timestamp }; existingUsers.push(newUser); localStorage.setItem('socialAppUsers', JSON.stringify(existingUsers));