howto create html css javascript halaman login in javascript

<!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>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
    <h1>Login</h1>
    <label for="username">Username:</label>
    <input type="text" id="username" placeholder="Enter Username">
    <label for="password">Password:</label>
    <input type="password" id="password" placeholder="Enter Password">
    <button onclick="login()">Login</button>
    <p id="message"></p>
</div>

<script src="script.js"></script>
</body>
</html>
614 chars
23 lines
body {
    font-family: Arial, sans-serif;
    background-color: #f3f3f3;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.container {
    background-color: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

input {
    width: 100%;
    padding: 8px;
    margin: 5px 0;
    box-sizing: border-box;
}

button {
    width: 100%;
    padding: 10px;
    border: 0;
    background-color: #007bff;
    color: white;
    cursor: pointer;
}

button:hover {
    background-color: #0056b3;
}
608 chars
38 lines
index.tsx
function login() {
    const username = document.getElementById('username').value;
    const password = document.getElementById('password').value;

    if(username === 'admin' && password === 'password'){
        document.getElementById('message').innerText = 'Login successful!';
    } else {
        document.getElementById('message').innerText = 'Invalid username or password. Please try again.';
    }
}
408 chars
11 lines

related categories

gistlibby LogSnag