togglePasswordVisibility
The togglePasswordVisibility function toggles the visibility of a password input field between ‘password’ and ‘text’ and updates the corresponding visibility icon.
Works in: React JS, HTML5
| Parameter | Type | Default | Description |
|---|---|---|---|
input | HTMLInputElement | undefined | The password input element. |
showIcon | string | HTMLElement | null | null | Icon for showing the password. |
hideIcon | string | HTMLElement | null | null | Icon for hiding the password. |
Usage
Example: Toggle Password Visibility
const passwordInputField = document.querySelector("input[type=password]");
const showIcon = '🙈';
const hideIcon = '👀';
nfsfu234FormValidation.togglePasswordVisibility(passwordInputField, showIcon, hideIcon);See also
Last updated on