How to Show hide password in Password textbox using checkbox using jquery?

Show hide password in Password textbox using checkbox

File name : index.php

<html lang="en">
<head>


<title>Show hide password in Password textbox using checkbox</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>


</head>
<body>


<div class="container">


<h2>Show hide password in Password textbox using checkbox</h2>


<input type="password" class="form-control my-password" name="password" />
<input type="checkbox" class="showPassword" />Show Password</div>


<script type="text/javascript">
$(document).ready(function(){
$('.showPassword').on('change',function(){
var isChecked = $(this).prop('checked');
if (isChecked) {
$('.my-password').attr('type','text');
} else {
$('.my-password').attr('type','Password');
}
});
});
</script>


</div>


</body>
</html>





Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here