/* Password Strength Meter CSS */ .password-strength-container { margin-top: 5px; height: 5px; background: #eee; border-radius: 3px; overflow: hidden; } .password-strength-bar { height: 100%; width: 0; transition: all 0.3s; } .strength-weak { background: #e74c3c; width: 33%; } .strength-medium { background: #f39c12; width: 66%; } .strength-strong { background: #2ecc71; width: 100%; } .password-hint { font-size: 11px; color: #7f8c8d; margin-top: 4px; display: block; } // Add this inside the DOMContentLoaded block in header.php // --- Password Strength Meter Logic --- const regPasswordInput = document.getElementById('regPassword'); const strengthBar = document.createElement('div'); strengthBar.className = 'password-strength-container'; strengthBar.innerHTML = '
'; const hint = document.createElement('small'); hint.className = 'password-hint'; hint.innerText = 'Must be 8+ chars, 1 uppercase, 1 lowercase, 1 number, 1 special.'; if (regPasswordInput) { regPasswordInput.parentNode.appendChild(strengthBar); regPasswordInput.parentNode.appendChild(hint); regPasswordInput.addEventListener('input', function() { const val = this.value; const innerBar = document.getElementById('strengthBarInner'); let strength = 0; if (val.length >= 8) strength++; if (/[A-Z]/.test(val) && /[a-z]/.test(val)) strength++; if (/\d/.test(val) && /[@$!%*?&]/.test(val)) strength++; innerBar.className = 'password-strength-bar'; if (strength === 1) innerBar.classList.add('strength-weak'); else if (strength === 2) innerBar.classList.add('strength-medium'); else if (strength === 3) innerBar.classList.add('strength-strong'); }); } // --- Secure Async Auth Processing Pipeline --- const responseBox = document.getElementById('authResponse'); function processFormSubmission(formId) { const form = document.getElementById(formId); if(!form) return; form.addEventListener('submit', function(e) { e.preventDefault(); responseBox.style.display = 'none'; // Find submit button and show loading state const submitBtn = this.querySelector('button[type="submit"]'); const originalText = submitBtn.innerText; submitBtn.innerText = 'Processing...'; submitBtn.disabled = true; const formData = new FormData(this); // Ensure action is correctly appended based on form ID if (formId === 'loginForm' && !formData.has('action')) formData.append('action', 'login'); if (formId === 'registerForm' && !formData.has('action')) formData.append('action', 'register'); fetch('/backend.php', { method: 'POST', body: formData }) .then(res => res.json()) .then(data => { responseBox.style.display = 'block'; responseBox.innerText = data.message; if(data.success === true) { responseBox.style.background = '#e8f5e9'; responseBox.style.color = '#2e7d32'; setTimeout(() => { window.location.reload(); }, 1500); } else { responseBox.style.background = '#ffebee'; responseBox.style.color = '#c62828'; } }) .catch(err => { console.error(err); responseBox.style.display = 'block'; responseBox.style.background = '#ffebee'; responseBox.style.color = '#c62828'; responseBox.innerText = 'Server error. Please try again.'; }) .finally(() => { submitBtn.innerText = originalText; submitBtn.disabled = false; }); }); } processFormSubmission('registerForm'); processFormSubmission('loginForm');
SEARCH

Search TestMarkaz.com

Your Favorite Questions

Submit Your MCQs | Contribute to TestMarkaz

Submit Your MCQ

Advertisement

🏆 Top Contributors

  • Ali Khan 128 MCQs
  • Fatima Ahmed 95 MCQs
  • Bilal Raza 72 MCQs
  • Ayesha Malik 61 MCQs
  • Saad Hussain 49 MCQs

📚 Popular MCQ Categories

Sidebar Menu

Leave a Reply / Ask a Question


Fatal error: Uncaught mysqli_sql_exception: Access denied for user 'u438193288_testmarkaz_db'@'localhost' (using password: YES) in /home/u438193288/domains/testmarkaz.com/public_html/footer.php:350 Stack trace: #0 /home/u438193288/domains/testmarkaz.com/public_html/footer.php(350): mysqli->__construct() #1 /home/u438193288/domains/testmarkaz.com/public_html/submit-mcqs.php(477): require_once('/home/u43819328...') #2 {main} thrown in /home/u438193288/domains/testmarkaz.com/public_html/footer.php on line 350