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

feat: Password Hide and Show button #843

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
112 changes: 111 additions & 1 deletion login/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
font-weight: 700;
letter-spacing: -1.5px;
margin: 0;
margin-bottom: 15px;
margin-top: 10px;
}

h1.title {
Expand Down Expand Up @@ -206,6 +206,116 @@
animation: show 0.6s;
}

#login-section{
display: flex;
align-items: center;
width: 100%;
}

#loginPassword{
position: relative;
}

#toggleLoginPassword{
position: absolute;
background: transparent;
border: none;
color: #505050;
right: 15%;
padding:2px;
transition: 0.3s ease-in-out;
}

#register-section{
display: flex;
align-items: center;
width: 100%;
}

#registerPassword{
position: relative;
}

#toggleRegisterPassword{
position: absolute;
background: transparent;
border: none;
color: #505050;
right: 15%;
padding:2px;
transition: 0.3s ease-in-out;
}

#confirmPassword{
position: relative;
}

#toggleConfirmPassword{
position: absolute;
background: transparent;
border: none;
color: #505050;
right: 15%;
padding:2px;
transition: 0.3s ease-in-out;
}

@media (max-width: 768px){
#login-section{
display: flex;
align-items: center;
}

#loginPassword{
position: relative;
}

#toggleLoginPassword{
position: absolute;
background: transparent;
border: none;
color: #505050;
right: 15%;
padding:2px;
letter-spacing: 1px;
text-transform: capitalize;
transition: 0.3s ease-in-out;
}
#register-section{
display: flex;
align-items: center;
}
#registerPassword{
position: relative;
}
#toggleRegisterPasswor{
position: absolute;
background: transparent;
border: none;
color: #505050;
right: 15%;
padding:2px;
letter-spacing: 1px;
text-transform: capitalize;
transition: 0.3s ease-in-out;
}

#confirmPassword{
position: relative;
}

#toggleConfirmPassword{
position: absolute;
background: transparent;
border: none;
color: #505050;
right: 15%;
padding:2px;
transition: 0.3s ease-in-out;
}
}


@keyframes show {
0%,
49.99% {
Expand Down
28 changes: 27 additions & 1 deletion login/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,30 @@ const registerButton = document.getElementById("register");

loginButton.addEventListener("click", () => {
container.classList.remove("right-panel-active");
});
});

function togglePasswordVisibility(buttonId, inputId, iconId) {
const passwordInput = document.getElementById(inputId);
const toggleButton = document.getElementById(buttonId);
const icon = document.getElementById(iconId);

toggleButton.addEventListener('click', function (e) {
// Toggle the type attribute
const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
passwordInput.setAttribute('type', type);

// Toggle the icon
if (type === 'password') {
icon.classList.remove('fa-eye-slash');
icon.classList.add('fa-eye');
} else {
icon.classList.remove('fa-eye');
icon.classList.add('fa-eye-slash');
}
});
}

// Apply the function to both login and register sections
togglePasswordVisibility('toggleLoginPassword', 'loginPassword', 'loginIcon');
togglePasswordVisibility('toggleRegisterPassword', 'registerPassword', 'registerIcon');
togglePasswordVisibility('toggleConfirmPassword', 'confirmPassword', 'confirmIcon');
24 changes: 21 additions & 3 deletions newLogin.html
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ <h1>Create Account</h1>
<title>TOUR GUIDE</title>
<link rel="icon" type="image/x-icon" href="log/favicon.ico">
<link href="https://cdn.lineicons.com/4.0/lineicons.css" rel="stylesheet" />
<script src="https://kit.fontawesome.com/f2e55912f8.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="/login/login.css">
<link rel="stylesheet" href="./login/login.css">
</head>
<body>
Expand All @@ -276,8 +278,19 @@ <h1>Create Account</h1>
<h1>TOUR GUIDE </h1>
<input type="text" placeholder="Name">
<input type="email" placeholder="Email">
<input type="password" placeholder="Password">
<input type="password" placeholder="Confirm Password">
<!-- <input type="password" placeholder="Password"> -->
<div id="register-section">
<input type="password" placeholder="Password" id="registerPassword">
<button type="button" id="toggleRegisterPassword">
<i id="registerIcon" class="fas fa-eye"></i>
</button>
</div>
<div id="register-section">
<input type="password" placeholder="Confirm Password" id="confirmPassword">
<button type="button" id="toggleConfirmPassword">
<i id="confirmIcon" class="fas fa-eye"></i>
</button>
</div>
<button onclick="refreshPage()">Register</button>
<script>
function refreshPage() {
Expand All @@ -299,7 +312,12 @@ <h1>TOUR GUIDE </h1>
<form action="#">
<h1>TOUR GUIDE</h1>
<input type="email" placeholder="Email">
<input type="password" placeholder="Password">
<div id="login-section">
<input type="password" placeholder="Password" id="loginPassword">
<button type="button" id="toggleLoginPassword">
<i id="loginIcon" class="fas fa-eye"></i>
</button>
</div>
<div class="content">
<div class="checkbox">
<input type="checkbox" name="checkbox" id="checkbox">
Expand Down
Loading