{% extends "base.html" %} {% block title %}Rejestracja - Norda Biznes Partner{% endblock %} {% block container_class %}container-narrow{% endblock %} {% block extra_css %} {% endblock %} {% block content %}
Norda Biznes

Utwórz konto

Dołącz do społeczności Norda Biznes

Podaj 10 cyfr bez spacji i myślników (np. 5882465814)
  • Minimum 8 znaków
  • Wielka litera
  • Mała litera
  • Cyfra
{% endblock %} {% block extra_js %} // Version: 2025-11-24 14:00 - Live checkbox validation console.log('🔧 Password validation loaded - Version 2025-11-24 14:00'); const passwordInput = document.getElementById('password'); const strengthBar = document.getElementById('strengthBar'); const submitBtn = document.getElementById('submitBtn'); // Password strength checker passwordInput.addEventListener('input', function() { const password = this.value; let strength = 0; let validCount = 0; // Check requirements const hasLength = password.length >= 8; const hasUpper = /[A-Z]/.test(password); const hasLower = /[a-z]/.test(password); const hasDigit = /\d/.test(password); // Update UI for each requirement updateRequirement('req-length', hasLength); updateRequirement('req-upper', hasUpper); updateRequirement('req-lower', hasLower); updateRequirement('req-digit', hasDigit); // Calculate strength if (hasLength) { strength++; validCount++; } if (hasUpper) { strength++; validCount++; } if (hasLower) { strength++; validCount++; } if (hasDigit) { strength++; validCount++; } // Update strength bar 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'); } // Enable submit button only if all requirements met submitBtn.disabled = validCount < 4; }); function updateRequirement(id, valid) { const el = document.getElementById(id); console.log(`Updating ${id}: ${valid ? 'VALID' : 'invalid'}`); // DEBUG if (valid) { el.classList.add('valid'); } else { el.classList.remove('valid'); } } // Form validation document.querySelector('form').addEventListener('submit', function(e) { const name = document.getElementById('name'); const email = document.getElementById('email'); const password = document.getElementById('password'); let valid = true; // Name validation if (!name.value || name.value.length < 2) { name.classList.add('error'); valid = false; } else { name.classList.remove('error'); } // Email validation if (!email.value || !email.value.includes('@')) { email.classList.add('error'); valid = false; } else { email.classList.remove('error'); } // Password validation const hasLength = password.value.length >= 8; const hasUpper = /[A-Z]/.test(password.value); const hasLower = /[a-z]/.test(password.value); const hasDigit = /\d/.test(password.value); if (!hasLength || !hasUpper || !hasLower || !hasDigit) { password.classList.add('error'); valid = false; } else { password.classList.remove('error'); } if (!valid) { e.preventDefault(); } }); // Email validation and availability check const emailInput = document.getElementById('email'); const emailStatus = document.getElementById('emailStatus'); let emailCheckTimeout; let emailAvailable = false; emailInput.addEventListener('input', function() { const email = this.value.trim(); // Clear previous timeout clearTimeout(emailCheckTimeout); // Basic format validation if (!email) { emailStatus.style.display = 'none'; emailAvailable = false; return; } // Proper email format validation const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/; if (!emailRegex.test(email)) { showEmailStatus('taken', '❌ Nieprawidłowy format email'); emailAvailable = false; return; } // Check availability after 500ms of no typing emailCheckTimeout = setTimeout(() => { checkEmailAvailability(email); }, 500); }); function checkEmailAvailability(email) { showEmailStatus('checking', '⏳ Sprawdzam dostępność...'); const csrfToken = document.querySelector('input[name="csrf_token"]').value; fetch('/api/check-email', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRFToken': csrfToken }, body: JSON.stringify({ email: email }) }) .then(response => response.json()) .then(data => { if (data.available) { showEmailStatus('available', '✅ Email dostępny'); emailAvailable = true; } else { showEmailStatus('taken', '❌ Email jest już zarejestrowany'); emailAvailable = false; } }) .catch(error => { console.error('Email check error:', error); emailStatus.style.display = 'none'; emailAvailable = false; }); } function showEmailStatus(statusClass, message) { emailStatus.className = 'email-status ' + statusClass; emailStatus.textContent = message; emailStatus.style.display = 'block'; } // NIP verification const verifyNipBtn = document.getElementById('verifyNipBtn'); const nipInput = document.getElementById('company_nip'); const nipStatus = document.getElementById('nipStatus'); let nipVerified = false; let isNordaMember = false; verifyNipBtn.addEventListener('click', function() { const nip = nipInput.value.trim(); // Validate NIP format (10 digits) if (!/^\d{10}$/.test(nip)) { showNipStatus('error', '❌ Nieprawidłowy format NIP. Podaj 10 cyfr.'); return; } // Show loading state showNipStatus('loading', '⏳ Sprawdzam NIP...'); verifyNipBtn.disabled = true; // Get CSRF token from form const csrfToken = document.querySelector('input[name="csrf_token"]').value; // Call API fetch('/api/verify-nip', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRFToken': csrfToken }, body: JSON.stringify({ nip: nip }) }) .then(response => response.json()) .then(data => { nipVerified = true; isNordaMember = data.is_member; if (data.is_member) { showNipStatus('norda-member', `✅ ${data.company_name}
Firma należy do sieci NORDA - Konto uprzywilejowane` ); } else { showNipStatus('non-member', `✅ NIP zweryfikowany
Firma spoza sieci NORDA - Konto standardowe` ); } }) .catch(error => { console.error('NIP verification error:', error); showNipStatus('error', '❌ Błąd weryfikacji NIP. Spróbuj ponownie.'); nipVerified = false; }) .finally(() => { verifyNipBtn.disabled = false; }); }); function showNipStatus(statusClass, message) { nipStatus.className = 'nip-status ' + statusClass; nipStatus.innerHTML = '' + message; nipStatus.style.display = 'flex'; } // Clear status when NIP is modified nipInput.addEventListener('input', function() { if (nipVerified) { nipStatus.style.display = 'none'; nipVerified = false; isNordaMember = false; } }); {% endblock %}