{% extends "base.html" %} {% block title %}Nowe haslo - Norda Biznes Hub{% endblock %} {% block container_class %}container-narrow{% endblock %} {% block extra_css %} {% endblock %} {% block content %}

Ustaw nowe haslo

Wprowadz nowe haslo do swojego konta

  • Minimum 8 znakow
  • Wielka litera
  • Mala litera
  • Cyfra
{% endblock %} {% block extra_js %} function showToast(message, type = 'info', duration = 4000) { const container = document.getElementById('toastContainer'); const icons = { error: '✕', info: 'ℹ' }; const toast = document.createElement('div'); toast.className = `toast ${type}`; toast.innerHTML = `${icons[type]||'ℹ'}${message}`; container.appendChild(toast); setTimeout(() => { toast.style.animation = 'toastOut 0.3s ease forwards'; setTimeout(() => toast.remove(), 300); }, duration); } const passwordInput = document.getElementById('password'); const passwordConfirm = document.getElementById('password_confirm'); const strengthBar = document.getElementById('strengthBar'); const submitBtn = document.getElementById('submitBtn'); passwordInput.addEventListener('input', function() { const password = this.value; let strength = 0; let validCount = 0; const hasLength = password.length >= 8; const hasUpper = /[A-Z]/.test(password); const hasLower = /[a-z]/.test(password); const hasDigit = /\d/.test(password); updateRequirement('req-length', hasLength); updateRequirement('req-upper', hasUpper); updateRequirement('req-lower', hasLower); updateRequirement('req-digit', hasDigit); if (hasLength) { strength++; validCount++; } if (hasUpper) { strength++; validCount++; } if (hasLower) { strength++; validCount++; } if (hasDigit) { strength++; validCount++; } strengthBar.className = 'password-strength-bar'; if (strength === 1 || strength === 2) { strengthBar.classList.add('weak'); } else if (strength === 3) { strengthBar.classList.add('medium'); } else if (strength === 4) { strengthBar.classList.add('strong'); } checkFormValidity(); }); passwordConfirm.addEventListener('input', checkFormValidity); function updateRequirement(id, valid) { const el = document.getElementById(id); if (valid) { el.classList.add('valid'); } else { el.classList.remove('valid'); } } function checkFormValidity() { const password = passwordInput.value; const confirm = passwordConfirm.value; const hasLength = password.length >= 8; const hasUpper = /[A-Z]/.test(password); const hasLower = /[a-z]/.test(password); const hasDigit = /\d/.test(password); const passwordsMatch = password === confirm && confirm.length > 0; submitBtn.disabled = !(hasLength && hasUpper && hasLower && hasDigit && passwordsMatch); } document.querySelector('form').addEventListener('submit', function(e) { const password = passwordInput.value; const confirm = passwordConfirm.value; if (password !== confirm) { passwordConfirm.classList.add('error'); e.preventDefault(); showToast('Hasła nie są identyczne', 'error'); } }); {% endblock %}