https://www.plus2net.com/jquery/checkbox-password.php
We can show or hide user entered text in a password by using a checkbox. When checkbox is checked the password entered will be visible and when it is not checked the password will not be visible and it will be masked.
Here we have used change event of checkbox to trigger the code. The type property is changed to text or password based on the checked status of the checkbox.
$(document).ready(function() {
/// Checkbox change event ///
$("#ckb").change(function(){
var ckb_status = $("#ckb").prop('checked');
if(ckb_status){$('#t1').prop('type', 'text');}// if checked
else{$('#t1').prop('type', 'password');} // if not checked
});
///End of checkbox change event//
});