34394-vm/assets/js/main.js
2025-09-25 18:33:53 +00:00

30 lines
1004 B
JavaScript

document.addEventListener('DOMContentLoaded', function () {
const loginForm = document.getElementById('loginForm');
if (loginForm) {
loginForm.addEventListener('submit', function (event) {
event.preventDefault();
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
// Basic client-side validation
if (!email || !password) {
alert('Please enter both email and password.');
return;
}
// Simple email format check
const emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
if (!emailRegex.test(email)) {
alert('Please enter a valid email address.');
return;
}
// On success, simulate login
console.log('Login validation passed. Redirecting...');
window.location.href = 'dashboard.php';
});
}
});