Skip to Content
NFSFU234FormValidation v3 is here — file upload validation, config-driven rules, and more.
v2 (legacy)togglePasswordVisibility

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

ParameterTypeDefaultDescription
inputHTMLInputElementundefinedThe password input element.
showIconstring | HTMLElement | nullnullIcon for showing the password.
hideIconstring | HTMLElement | nullnullIcon 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