"Password Show & Hide"
Bootstrap 4.1.1 Snippet by SANTANU CHOWDHURY

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-4 col-xs-4">
<form>
<div class="form-group form-group__eyes">
<label for="passwordEyes">Password</label>
<input class="form-control" id="passwordEyes" placeholder="Password" type="password">
<img class="eyes" onclick="textChange(this)" src="https://i.ibb.co/Hp0xx9P/hide.png" alt="">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
.form-group__eyes{
position: relative;
}
.eyes{
right: 10px;
top: 43px;
position: absolute;
width: 16px;
cursor: pointer;
opacity: .8;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
let pass = document.getElementById('passwordEyes');
function textChange(x){
let a = x.src;
if(a=="https://i.ibb.co/Hp0xx9P/hide.png"){
x.src = "https://i.ibb.co/6PyYnFW/view.png";
pass.type = "text";
}
else{
x.src = "https://i.ibb.co/Hp0xx9P/hide.png";
pass.type = "password";
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: