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

Added Show/Hide password in signup page #447

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
19 changes: 18 additions & 1 deletion src/css/signup.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,21 @@ label {

#passwordlim{
color: white;
}
}
.field-icon{
float: right;
font-size:24px;
display: flex;
align-items: center;
}
.fa-eye, .fa-eye-slash{
position: absolute;
top: 6px;
right: 5px;
z-index: 15;
display: block;
width: 34px;
height: 34px;
line-height: 34px;
text-align: center;
}
22 changes: 22 additions & 0 deletions src/js/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ var signupBlock = document.getElementById("signedup");
var BASE_URL = "https://api.susi.ai";
var passwordlim = document.getElementById("passwordlim");
var password = document.getElementById("password");
var toggle = document.getElementById("toggle");
var cptoggle = document.getElementById("cptoggle");

window.onload = () => {
showsignupBlock(true);
Expand All @@ -21,6 +23,26 @@ let showsignupBlock = (show) => {
}
};

toggle.addEventListener("click", ()=>{
toggle.classList.toggle("fa-eye");
toggle.classList.toggle("fa-eye-slash");
if (toggle.classList.contains("fa-eye-slash")) {
document.getElementById("password").type = "password";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of document.getElementById("password") you can use password

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same at line 32.

} else {
document.getElementById("password").type = "text";
}
});

cptoggle.addEventListener("click", ()=>{
cptoggle.classList.toggle("fa-eye");
cptoggle.classList.toggle("fa-eye-slash");
if (cptoggle.classList.contains("fa-eye-slash")) {
document.getElementById("cpassword").type = "password";
} else {
document.getElementById("cpassword").type = "text";
}
});

password.addEventListener("keyup", ()=>{
if(password.value.length<6){
passwordlim.removeAttribute("hidden");
Expand Down
23 changes: 19 additions & 4 deletions src/signup.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<!DOCTYPE html>
<html>

<head>
<title>SUSI Login Portal</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css"
integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/signup.css">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
</head>

<body>
<div class="container">
<div class="row">
Expand All @@ -22,15 +26,25 @@
<br />
<div class="form-group">
<label for="password">Password:</label>
<input type="password" class="form-control" id="password" placeholder="Enter your password">
<div class="input-group">
<input type="password" class="form-control" id="password" placeholder="Enter your password">
<span class="field-icon">
<i class="fa fa-eye" id="toggle"></i>
</span>
</div>
<div style="text-align: center">
<small hidden id="passwordlim">Minimum 6 characters required</small>
</div>
</div>
<br />
<div class="form-group">
<label for="password">Confirm Password:</label>
<input type="password" class="form-control" id="cpassword" placeholder="Confirm Password">
<div class="input-group">
<input type="password" class="form-control" id="cpassword" placeholder="Confirm Password">
<span class="field-icon">
<i class="fa fa-eye" id="cptoggle"></i>
</span>
</div>
</div>
<br>
<button disabled type="submit" class="btn btn-success" id="signupbutton">Signup</button>
Expand All @@ -56,4 +70,5 @@
<script src="bootstrap/bootstrap.min.js"></script>
<script src="js/signup.js"></script>
</body>
</html>

</html>