Page 1 of 1

JavaScript code for changing object type onclick

Posted: Thu Nov 02, 2023 12:58 pm
by andrea763
Hello gusy, i've a password field on a edit form, i'd like to view in clear the contained text when i onlick on it.,
Is it possible with javascript?
How?
greetings

Re: JavaScript code for changing object type onclick

Posted: Thu Nov 02, 2023 1:15 pm
by kev1n
Hi,

Add this function in your form's Custom Code:

Code: Select all

function showPassword(element, showPassword) {
  element.type = showPassword ? 'text' : 'password';
}
Next, add these two events to your password field:
events.png
So, when you click on the password field with the mouse, the characters are unmasked and become visible. When the field loses focus, the characters are masked again.

Re: JavaScript code for changing object type onclick

Posted: Thu Nov 02, 2023 1:29 pm
by andrea763
Wow. Thanks a lot.