195 lines
8.7 KiB
Plaintext
195 lines
8.7 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><%= title %></title>
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
|
<link href="/css/style.css" rel="stylesheet">
|
|
</head>
|
|
<body class="bg-light">
|
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
|
<div class="container">
|
|
<a class="navbar-brand d-flex align-items-center" href="/">
|
|
<img src="/images/logo.png" alt="EduCat Logo" height="40" class="me-2">
|
|
<span class="fw-bold">EduCat</span>
|
|
</a>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container-fluid vh-100 d-flex align-items-center justify-content-center bg-light">
|
|
<div class="row w-100">
|
|
<div class="col-md-6 col-lg-5 mx-auto">
|
|
<div class="card shadow-lg border-0">
|
|
<div class="card-body p-5">
|
|
<div class="text-center mb-4">
|
|
<img src="/images/logo.png" alt="EduCat Logo" height="80" class="mb-3">
|
|
<h2 class="mb-2">Join EduCat!</h2>
|
|
<p class="text-muted">Create your account to get started</p>
|
|
</div>
|
|
|
|
<!-- Display flash messages -->
|
|
<% if (messages.error) { %>
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
<%= messages.error %>
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
<% } %>
|
|
|
|
<% if (messages.success) { %>
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<i class="fas fa-check-circle me-2"></i>
|
|
<%= messages.success %>
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
<% } %>
|
|
|
|
<form action="/register" method="POST" id="registerForm">
|
|
<div class="mb-3">
|
|
<label for="name" class="form-label">Full Name</label>
|
|
<div class="input-group">
|
|
<span class="input-group-text">
|
|
<i class="fas fa-user"></i>
|
|
</span>
|
|
<input type="text" class="form-control" id="name" name="name" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="username" class="form-label">Username</label>
|
|
<div class="input-group">
|
|
<span class="input-group-text">
|
|
<i class="fas fa-at"></i>
|
|
</span>
|
|
<input type="text" class="form-control" id="username" name="username" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="email" class="form-label">Email Address</label>
|
|
<div class="input-group">
|
|
<span class="input-group-text">
|
|
<i class="fas fa-envelope"></i>
|
|
</span>
|
|
<input type="email" class="form-control" id="email" name="email" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="password" class="form-label">Password</label>
|
|
<div class="input-group">
|
|
<span class="input-group-text">
|
|
<i class="fas fa-lock"></i>
|
|
</span>
|
|
<input type="password" class="form-control" id="password" name="password" required minlength="6">
|
|
<button type="button" class="btn btn-outline-secondary" onclick="togglePassword('password')">
|
|
<i class="fas fa-eye" id="toggleIcon1"></i>
|
|
</button>
|
|
</div>
|
|
<small class="text-muted">Password must be at least 6 characters long</small>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="confirmPassword" class="form-label">Confirm Password</label>
|
|
<div class="input-group">
|
|
<span class="input-group-text">
|
|
<i class="fas fa-lock"></i>
|
|
</span>
|
|
<input type="password" class="form-control" id="confirmPassword" name="confirmPassword" required minlength="6">
|
|
<button type="button" class="btn btn-outline-secondary" onclick="togglePassword('confirmPassword')">
|
|
<i class="fas fa-eye" id="toggleIcon2"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="d-grid gap-2 mb-3">
|
|
<button type="submit" class="btn btn-primary btn-lg">
|
|
<i class="fas fa-user-plus me-2"></i>Create Account
|
|
</button>
|
|
</div>
|
|
</form>
|
|
|
|
<div class="text-center">
|
|
<p class="text-muted">Already have an account?
|
|
<a href="/login" class="text-primary text-decoration-none">Sign in here</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function togglePassword(fieldId) {
|
|
const passwordInput = document.getElementById(fieldId);
|
|
const toggleIcon = document.getElementById(fieldId === 'password' ? 'toggleIcon1' : 'toggleIcon2');
|
|
|
|
if (passwordInput.type === 'password') {
|
|
passwordInput.type = 'text';
|
|
toggleIcon.classList.remove('fa-eye');
|
|
toggleIcon.classList.add('fa-eye-slash');
|
|
} else {
|
|
passwordInput.type = 'password';
|
|
toggleIcon.classList.remove('fa-eye-slash');
|
|
toggleIcon.classList.add('fa-eye');
|
|
}
|
|
}
|
|
|
|
// Form validation
|
|
document.getElementById('registerForm').addEventListener('submit', function(e) {
|
|
const name = document.getElementById('name').value.trim();
|
|
const username = document.getElementById('username').value.trim();
|
|
const email = document.getElementById('email').value.trim();
|
|
const password = document.getElementById('password').value;
|
|
const confirmPassword = document.getElementById('confirmPassword').value;
|
|
|
|
if (!name || !username || !email || !password || !confirmPassword) {
|
|
e.preventDefault();
|
|
alert('Please fill in all fields');
|
|
return;
|
|
}
|
|
|
|
if (password !== confirmPassword) {
|
|
e.preventDefault();
|
|
alert('Passwords do not match');
|
|
return;
|
|
}
|
|
|
|
if (password.length < 6) {
|
|
e.preventDefault();
|
|
alert('Password must be at least 6 characters long');
|
|
return;
|
|
}
|
|
|
|
// Basic email validation
|
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
if (!emailRegex.test(email)) {
|
|
e.preventDefault();
|
|
alert('Please enter a valid email address');
|
|
return;
|
|
}
|
|
});
|
|
|
|
// Real-time password confirmation
|
|
document.getElementById('confirmPassword').addEventListener('input', function() {
|
|
const password = document.getElementById('password').value;
|
|
const confirmPassword = this.value;
|
|
|
|
if (password !== confirmPassword) {
|
|
this.setCustomValidity('Passwords do not match');
|
|
this.classList.add('is-invalid');
|
|
} else {
|
|
this.setCustomValidity('');
|
|
this.classList.remove('is-invalid');
|
|
this.classList.add('is-valid');
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|