Show Password – jQuery

In this post, we are going to take a look at a simple functionality which allows us to show password with help of check box.

See Also: How to get element by href in jquery?

HTML:

<div>
	<input type="password" id="password" name="password" />&nbsp;&nbsp;
	<input type="checkbox" id="showPass" />Show Password</div>
</div>

 jQuery:

$(document).ready(function(){
	$('#showPass').on('change',function(){
		var isChecked = $(this).prop('checked');
		if (isChecked) {
			$('#password').attr('type','text');
		} else {
			$('#password').attr('type','Password');
		}
	});
});

Click Here to view working demo.

0 Comments

Leave a Comment.