uswds
Version:
Open source UI components and visual style guide for U.S. government websites
11 lines (10 loc) • 431 B
JavaScript
/**
* Flips given INPUT elements between masked (hiding the field value) and unmasked
* @param {Array.HTMLElement} fields - An array of INPUT elements
* @param {Boolean} mask - Whether the mask should be applied, hiding the field value
*/
module.exports = (field, mask) => {
field.setAttribute('autocapitalize', 'off');
field.setAttribute('autocorrect', 'off');
field.setAttribute('type', mask ? 'password' : 'text');
};