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 for js functionality #50

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
24 changes: 22 additions & 2 deletions login/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<body>
<div class="login-container">
<h1>Login to Your Account</h1>
<form action="#" method="post">
<form id="loginForm" method="post" onsubmit="return validateForm()">
<div class="input-group">
<label for="username">Username</label>
<input type="text" id="username" name="username" required>
Expand All @@ -23,8 +23,28 @@ <h1>Login to Your Account</h1>
</form>
<div class="links">
<a href="#">Forgot Password?</a>
<a href="../SignUp/signup.html">Sign Up</a>
<a href="../signup/signup.html">Sign Up</a>
</div>
</div>

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the js code to another file like login.js not here.

<script>
// JavaScript Form Validation
function validateForm() {
const username = document.getElementById("username").value;
const password = document.getElementById("password").value;

if (username === "" || password === "") {
alert("Please fill out all fields.");
return false;
}


// Redirect to the specific URL on successful login
alert("Login successful!");
window.location.href = "../index.html"; // Absolute URL redirection
return false; // Prevent actual form submission
}
</script>
</body>
</html>