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

Login Successful with Wrong Email #271

Merged
merged 2 commits into from
Oct 8, 2024
Merged
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
41 changes: 37 additions & 4 deletions Html-files/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,21 @@
</div>
</div>
</div>
<form action="">
<form id="loginForm" action="logged.html">
<div class="right-login">
<div class="card-login">
<h1 style="color: hsl(203, 30%,26%);font-family: var(--ff-philosopher);">LOGIN</h1>
<div class="textfield">
<label for="usuario" style="color: black;font-family:var(--ff-poppins);">Email / User Name</label>
<input required type="text" name="email" placeholder="Enter Email / UserName" style="font-family:var(--ff-poppins);">
<input required type="text" id="email" name="email" placeholder="Enter Email / UserName" style="font-family:var(--ff-poppins);">
</div>
<div class="textfield">
<label required for="password" style="color: black;font-family:var(--ff-poppins);">Password</label>
<input required type="password" name="password" placeholder="Enter Password" style="font-family:var(--ff-poppins);">
<input required type="password" id="password" name="password" placeholder="Enter Password" style="font-family:var(--ff-poppins);">
</div>
<button class="btn-login" style="color: black;font-family:var(--ff-poppins);"><a style="text-decoration: none;color: black;" href="logged.html">Login</a></button>
<button type="submit" class="btn-login" style="color: black;font-family:var(--ff-poppins);">Login</button>
<button id="google-login" style="color: black;font-family:var(--ff-poppins);">Login with google</button>
<p id="error-message" style="color: red; font-family: var(--ff-poppins);"></p>
</div>
</div>
</form>
Expand Down Expand Up @@ -211,6 +212,38 @@ <h1 style="color: hsl(203, 30%,26%);font-family: var(--ff-philosopher);">LOGIN</
}

animateCircles();

// Form submission event listener
document.getElementById('loginForm').addEventListener('submit', function(event) {
// Prevent form submission
event.preventDefault();

// Get the input values
const emailInput = document.getElementById('email').value;
const passwordInput = document.getElementById('password').value;

// Regular expression for email validation (simple check)
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

// Password validation (at least 8 characters)
const isValidPassword = passwordInput.length >= 8;

// Clear previous error message
document.getElementById('error-message').textContent = '';

// Validate the email and password separately
if (!emailPattern.test(emailInput)) {
// Display an error message if the email format is incorrect
document.getElementById('error-message').textContent = 'Invalid email format.';
} else if (!isValidPassword) {
// Display an error message if the password is too short
document.getElementById('error-message').textContent = 'Password must be at least 8 characters.';
} else {
// If both are valid, redirect to logged.html
window.location.assign('logged.html');
}
});

</script>
</body>
</html>