Skip to content

Instantly share code, notes, and snippets.

@dislokacia
Last active May 3, 2024 10:54
Show Gist options
  • Save dislokacia/20b82b36ba9babf064de658fe35312f1 to your computer and use it in GitHub Desktop.
Save dislokacia/20b82b36ba9babf064de658fe35312f1 to your computer and use it in GitHub Desktop.
Password visibility JetFormBuilder
input.pass_vis:checked + i:before {
content: "\f070";
}
jQuery(document).ready(function( $ ){
$('.jet-form-builder input[type="password"]').each(function(){
let id = $(this).attr('id');
if($(this).length>0){
$(this).closest('div').append(`<label><input class="pass_vis" style="display:none;" type="checkbox" onclick="myFunction('${id}')"><i class="vis-icon fa fa-solid fa-eye"></i></label>`);
let offset = ($(this)[0].clientHeight - $('.vis-icon')[0].clientHeight)/2;
$(this).closest('div').css('position', 'relative');
$(this).siblings().css({
'position' : 'absolute',
'right' : '20px',
'top' : `${offset}px`,
'cursor': 'pointer'
});
}
})
});
function myFunction(id) {
var x = document.getElementById(`${id}`);
if (x.type === "password") {
x.type = "text";
} else {
x.type = "password";
}
}
@dislokacia
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment