Login page UI
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Page</title>
<style>
body {
font-family: Arial, sans-serif;
}
.container {
width: 50%;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 10px;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
}
.form-group input {
width: 100%;
padding: 8px;
box-sizing: border-box;
}
.error {
color: red;
display: none;
}
</style>
</head>
<body>
<div class="container">
<h1>Login</h1>
<form id="loginForm">
<div class="form-group">
<label for="id">Customer ID</label>
<input type="text" id="id" name="id" required>
<div class="error" id="idError">ID not valid.</div>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" required>
<div class="error" id="passwordError">Password not valid.</div>
</div>
<button type="button" onclick="login()">Login</button>
</form>
</div>
<script>
function login() {
// Get form values
const id = document.getElementById('id').value;
const password = document.getElementById('password').value;
// Validate form
let valid = true;
document.querySelectorAll('.error').forEach(error => error.style.display = 'none');
if (id !== 'expectedID') { // Replace 'expectedID' with the actual logic for validating ID
document.getElementById('idError').style.display = 'block';
valid = false;
}
if (password !== 'expectedPassword') { // Replace 'expectedPassword' with the actual logic for validating password
document.getElementById('passwordError').style.display = 'block';
valid = false;
}
if (valid) {
// Simulate login success
window.location.href = 'homepage.html'; // Redirect to homepage
}
}
</script>
</body>
</html>
Comments
Post a Comment