password-revealer

1.1.1 • Public • Published

password-revealer.js npm version Build Status

Easily reveal/hide passwords in input fields.

Motivation

Mainly because the "Confirm Password" field must die.

Install

Get it using npm:

npm install password-revealer --save

Or download the ZIP file and use it as you want.

Usage

See basic demo (without npm) and live examples.

Using npm:

import PasswordRevealer from 'password-revealer' // ES2015 module syntax
 
PasswordRevealer('#password-field')

PasswordRevealer(input[, options])

input

Type: string or HTMLElement

Input field that will have its password revealed or hidden.

options

Type: object

options.isRevealed

Type: boolean
Default: false

Initial state of the password. When true, the input's password value is automatically revealed.

options.trigger.selector

Type: string or HTMLElement
Default: .PasswordRevealer-trigger

Element that reveals or hides the password ("trigger").

options.trigger.eventListener

Type: string
Default: click

Event that will be attached to the trigger, in the case you are initializing a trigger.

API

Interact with a PasswordRevealer instance using the methods below.

.init()

It initializes, in a element with the selector provided in options, the trigger that reveals or hides the password.

.show()

It reveals the password for the input provided in the instance.

.hide()

It hides the password for the input provided in the instance.

.toggle()

It reveals or hides the password for the input provided in the instance, depending on the current state of the input.

TODO

  • Emit custom events.
  • Create a default trigger in the DOM when calling init().

License

MIT

Package Sidebar

Install

npm i password-revealer

Weekly Downloads

366

Version

1.1.1

License

MIT

Last publish

Collaborators

  • diessica