Complete Code For Showing Password On Click Of Checkbox With Javascript.
<!DOCTYPE html>
<html>
<head>
<title>How To Show Password On Click Of Checkbox With Javascript</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<style>
*{
box-sizing: border-box;
}
body{
background: black;
}
</style>
<body>
<br/><br/>
<div class="container">
<br>
<div class="text-center">
<h1 id="color" style="color: white;">Show Password On Click Of Checkbox With Javascript</h1>
</div>
<br><br><br>
<div class="well">
<label>Password: </label>
<input class="form-control" type="password" value="Ampassword" id="myInput"><br><br>
<input type="checkbox" onclick="myFunction()">Show Password
</div>
</div>
</body>
</html>
<script>
function myFunction() {
var x = document.getElementById("myInput");
if (x.type === "password") {
x.type = "text";
} else {
x.type = "password";
}
}
</script>