togglePasswordVisibility
Toggles a single password field between masked and visible, swapping
an optional show/hide icon accordingly.
Returns: any
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
input | HTMLInputElement | required | - | The password input to toggle. |
showIcon | `null \ | string \ | HTMLElement` | optional |
hideIcon | `null \ | string \ | HTMLElement` | optional |
Usage
Example: Toggle Password Visibility
const passwordInputField = document.querySelector("input[type=password]");
const showIcon = '🙈';
const hideIcon = '👀';
nfsfu234FormValidation.togglePasswordVisibility(passwordInputField, showIcon, hideIcon);Last updated on