I've several fields that are very similar and contain passwords, so I've assigned a class to them and I'm now trying to show and hide the password or plain text.
$("body").on( 'click', '.show', function () {
$id = $(this).attr('id')
if ($('#' + $id).prop('type') == 'password') {
$('#' + $id).addClass('hide').removeClass('show');
$('#' + $id).prop('type', 'text');
setTimeout( function() {
$('#' + $id).prop('type', 'password');
$('#' + $id).addClass('show').removeClass('hide');
}, 2500);
}
})
This works fine for each field and as I click into them the correct password is shown and it is reverted back to a password field after 2.5 seconds.
The issue I have is if I click one field, then another, then another each is shown but only the last one reverts back.
How do I get this to revert them back to a password field even if other fields call this function ?
Thanks
The form fields are similar to the following:
<input class='show' type='password' id='access' name='access' value='' >