Skip to content

Commit

Permalink
Merge pull request #424 from RNAdvani/feature/toggle-show-password
Browse files Browse the repository at this point in the history
feat: add toggle for password visibility
  • Loading branch information
Harshdev098 authored Nov 10, 2024
2 parents b81cb54 + c6316ba commit a73014b
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 2 deletions.
20 changes: 20 additions & 0 deletions public/css/login_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,23 @@ button:hover {
border: 1px solid #f5c6cb;
display: none;
}


.password-container {
position: relative;
width: 100%;
margin-bottom: 15px;
}

#toggle-password {
position: absolute;
top: 0%;
right: 10px;
transform: translateY(50%);
cursor: pointer;
}

#toggle-password img {
width: 20px;
height: 20px;
}
Binary file added public/images/eye-closed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/eye-open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion public/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ <h4 style="text-align: center; margin: 10px 0px 6px 0px;font-size: 22px;">(for R
<label for="email">Email:</label>
<input type="email" id="email" name="email" placeholder="Enter your email" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" placeholder="Enter your password" required>
<div class="password-container">
<input type="password" id="password" name="password" placeholder="Enter your password" required>
<span id="toggle-password">
<img src="images/eye-closed.png" id="eye-icon" alt="Show/Hide Password" style="cursor: pointer;">
</span>
</div>
<a href="password_reset.html">Forgot Password?</a>
<button type="button" onclick="login()">Login</button>
<div class="register">
Expand Down Expand Up @@ -77,6 +82,21 @@ <h4 style="text-align: center; margin: 10px 0px 6px 0px;font-size: 22px;">(for R
return allowedDomains.includes(domain);
}

const togglePassword = document.getElementById('toggle-password');
const passwordInput = document.getElementById('password');
const eyeIcon = document.getElementById('eye-icon');

togglePassword.onclick = function () {
if (passwordInput.type === 'password') {
passwordInput.type = 'text';
eyeIcon.src = 'images/eye-open.png';
} else {
passwordInput.type = 'password';
eyeIcon.src = 'images/eye-closed.png';
}
}


async function login() {
let email = document.getElementById("email").value;
let password = document.getElementById("password").value;
Expand Down
21 changes: 20 additions & 1 deletion public/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ <h4 style="text-align: center; margin: 6px 0px 10px 0px;font-size: 22px;">(for R
Icloud, or Tutanota.</span>

<label for="password">Password:</label>
<input type="password" id="password" name="password" placeholder="Enter the Password" required>
<div class="password-container">
<input type="password" id="password" name="password" placeholder="Enter your password" required>
<span id="toggle-password">
<img src="images/eye-closed.png" id="eye-icon" alt="Show/Hide Password" style="cursor: pointer;">
</span>
</div>
<ul id="password-criteria" class="criteria">
<li id="length">At least 8 characters long</li>
<li id="uppercase">At least 1 uppercase letter (A-Z)</li>
Expand Down Expand Up @@ -199,6 +204,20 @@ <h4 style="text-align: center; margin: 6px 0px 10px 0px;font-size: 22px;">(for R
});
});

const togglePassword = document.getElementById('toggle-password');
const passwordInput = document.getElementById('password');
const eyeIcon = document.getElementById('eye-icon');

togglePassword.onclick = function () {
if (passwordInput.type === 'password') {
passwordInput.type = 'text';
eyeIcon.src = 'images/eye-open.png';
} else {
passwordInput.type = 'password';
eyeIcon.src = 'images/eye-closed.png';
}
}

document.getElementById('registrationForm').addEventListener('submit', async function (event) {
event.preventDefault();

Expand Down

0 comments on commit a73014b

Please sign in to comment.