Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update login.html #147

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 50 additions & 38 deletions login.html
Original file line number Diff line number Diff line change
@@ -1,64 +1,76 @@
<!DOCTYPE html>
<html lang="en">

<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<title>Login Page</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<style>
.login-container{
width: 500px;
height: 450px;
position: relative;
top: 100px;
left: 450px;
.login-container {
max-width: 500px;
margin: 100px auto; /* Centers the container */
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.back-button {
margin: 10px;
text-align: right;
}
</style>
</head>

<body>
<div style="text-align: right; margin: 10px;">
<a href="index.html" class="btn btn-secondary" style="width: 150px; position: relative; right: 1330px;">Back to Home</a>
<div class="back-button">
<a href="index.html" class="btn btn-secondary" style="width: 150px;">Back to Home</a>
</div>
<div class="login-container" style="padding-top: 20px;">
<h2 style="text-align: center;">Login</h2>
<div class="mb-3" style="margin-left: 40px;">
<label for="exampleFormControlInput1" class="form-label">Email address</label>
<input type="email" class="form-control" id="emailInput" placeholder="name@example.com" style="width: 400px;">
</div>
<div class="mb-3" style="margin-left: 40px;">
<label for="inputPassword5" class="form-label">Password</label>
<input type="password" id="passwordInput" class="form-control" aria-describedby="passwordHelpBlock" style="width: 400px">
<div id="passwordHelpBlock" class="form-text" style="width: 400px">
Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
</div>
</div>
<button type="button" class="btn btn-primary" id="loginButton" style="width: 400px; margin-left: 40px;">Login</button>
<div style="text-align: center; margin-top: 10px;">
<p>Don't have an accout ? <a href="signup.html" style="text-decoration: none;"> Sign UP</a></p>
<p style="text-align: center;"><a href="#" style=" text-decoration: none;">Forget Password</a></p>
</div>

<div class="login-container">
<h2 class="text-center">Login</h2>
<form id="loginForm"> <!-- Added form element -->
<div class="mb-3">
<label for="emailInput" class="form-label">Email address</label>
<input type="email" class="form-control" id="emailInput" placeholder="name@example.com" required>
</div>
<div class="mb-3">
<label for="passwordInput" class="form-label">Password</label>
<input type="password" id="passwordInput" class="form-control" aria-describedby="passwordHelpBlock" required>
<div id="passwordHelpBlock" class="form-text">
Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
</div>
</div>
<button type="submit" class="btn btn-primary" style="width: 100%;">Login</button> <!-- Changed button type to submit -->
</form>
<div class="text-center mt-2">
<p>Don't have an account? <a href="signup.html" style="text-decoration: none;">Sign Up</a></p>
<p><a href="#" style="text-decoration: none;">Forget Password</a></p>
</div>
</div>

<script>
document.getElementById('loginButton').addEventListener('click', function() {
document.getElementById('loginForm').addEventListener('submit', function (event) {
event.preventDefault(); // Prevent form submission

const emailInput = document.getElementById('emailInput');
const passwordInput = document.getElementById('passwordInput');
const emailValue = emailInput.value.trim();
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
if (!emailRegex.test(emailValue)) {
alert('Invalid email address');
return;
}
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;

if (!emailRegex.test(emailValue)) {
alert('Invalid email address');
return;
}

alert('Login successful!'); // Show alert before clearing inputs
emailInput.value = '';
passwordInput.value = '';
// Redirect to index.html
window.location.href = '/index.html';
alert('Login successful!');
window.location.href = '/index.html'; // Redirect after alert
});
</script>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>

</html>