Skip to content

Commit

Permalink
Make show hide password
Browse files Browse the repository at this point in the history
  • Loading branch information
SMD-1 committed May 31, 2022
1 parent 8d90e14 commit 304bda7
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
30 changes: 30 additions & 0 deletions ShowHidePassword/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.15.4/css/all.css"
integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm"
crossorigin="anonymous"
/>
<title>Show Hide Password</title>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<div class="inputBox">
<input id="password" type="password" placeholder="Enter your password" />
<div id="toggle">
<i
id="icon"
class="fas fa-eye-slash fa-2x"
onclick="showHide();"
style="padding: 5px"
></i>
</div>
</div>

<script src="./script.js"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions ShowHidePassword/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const password = document.getElementById("password");
const toggle = document.getElementById("toggle");
const icon = document.getElementById("icon");
function showHide() {
if (password.type === "password") {
password.setAttribute("type", "text");
toggle.classList.remove("hide");
icon.classList.remove("fa-eye-slash");
icon.classList.add("fa-eye");
} else {
password.setAttribute("type", "password");
toggle.classList.add("hide");
icon.classList.add("fa-eye-slash");
}
}
50 changes: 50 additions & 0 deletions ShowHidePassword/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
* {
margin: 0;
padding: 0;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #f8f8f8;
}
.inputBox {
position: relative;
width: 400px;
height: 60px;
}
.inputBox input {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
font-size: 25px;
padding: 15px;
outline: none;
border: none;
border-radius: 8px;
background: transparent;
box-sizing: border-box;
box-shadow: -4px -4px 10px rgba(255, 255, 255, 1),
inset 4px 4px 10px rgba(0, 0, 0, 0.05),
inset -4px -4px 10px rgba(255, 255, 255, 1),
4px 4px 10px rgba(0, 0, 0, 0.05);
}
.inputBox input::placeholder {
color: rgb(146, 140, 140);
}
#toggle {
position: absolute;
top: 10px;
right: 10px;
width: 45px;
height: 30px;
background-size: cover;
padding: 5px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}

0 comments on commit 304bda7

Please sign in to comment.