To have show/hide option in the password field I have tried a few methods including having two fields and show hide based on state, but it has problems.
Here is the way to do it.
Layout Structure
- Password field and show hide icon inside a group. You can choose password field type as “password” by default.
- Name the group “Password Parent” (name can be anything, it’s just for recognizing)
- Create a custom state for “Password Parent” as “Password Show” and type can be “Yes/No”. You can leave the default state as blank.
- Create condition for show/hide icon (default eye icon), if “Group Password Parent’s Password Show is Yes” then change the icon to hide password (icon with cross line).
- Add id for the password field “password”
When clicking on the show/hide icon do the following (default will be eye icon without cross line)
Set State
- If the icon is show password, Set state for the “Password Parent” as “Password Show” - “Yes” and
- If the icon is hide password, Set state for the “Password Parent” as “Password Show” - “No”
In workflow add this
- Do when condition is true (don’t forget to choose “Every Time”), Only when “Group Password Parent’s Password Show is Yes”
Run Javascript
$(’#password’).get(0).type = ‘text’;
- Do when condition is true (don’t forget to choose “Every Time”), Only when “Group Password Parent’s Password Show is No”
Run Javascript
$(’#password’).get(0).type = ‘password’;