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 fix: Password visibility #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
36 changes: 36 additions & 0 deletions fix: Password visibility
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,39 @@
font-size: 12px;
display: none;
}
.toggle-password {
display: flex; /* Use flexbox to align items */
justify-content: center; /* Center items horizontally */
align-items: center; /* Center items vertically */
font-size: 12px;
margin-top: 5px;
}
.toggle-password input {
margin-left: 5px; /* Space between label and checkbox */
margin-top: 0; /* Reset margin-top for better alignment */
}
</style>
<script>
function togglePasswordVisibility() {
const passwordField = document.getElementById("password");
passwordField.type = passwordField.type === "password" ? "text" : "password";
}

document.addEventListener('DOMContentLoaded', function() {
document.querySelector('form').addEventListener('submit', function(event) {
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
const errorMessage = document.querySelector('.error-message');

if (!username || !password) {
event.preventDefault();
errorMessage.style.display = 'block';
} else {
errorMessage.style.display = 'none';
}
});
});
</script>
</head>
<body>
<div class="login-container">
Expand All @@ -67,6 +99,10 @@
<div class="form-group">
<label for="password">Password:</label>
<input type="password" id="password" name="password" placeholder="Enter your password" required>
<div class="toggle-password">
<label for="show-password">Show Password</label>
<input type="checkbox" id="show-password" aria-label="Show password" onclick="togglePasswordVisibility()">
</div>
</div>
<div class="error-message">Error: Username or password cannot be empty.</div>
<button type="submit" class="btn">Login</button>
Expand Down