Last active
May 3, 2024 10:54
-
-
Save dislokacia/20b82b36ba9babf064de658fe35312f1 to your computer and use it in GitHub Desktop.
Password visibility JetFormBuilder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input.pass_vis:checked + i:before { | |
content: "\f070"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gyazo.com/12f07fd7bf1360dcb87e0cb79c377036