Back to index
|
Fork me on github
jquery-showpassword
A jQuery (> 1.3.0) plugin that allows users to trigger the transformation of a password field into a cleartext field and vice versa from a DOM event.
© Copyright 2012 Christophe Pollet
Licensed under the MIT License (http://www.opensource.org/licenses/mit-license.php)
Demo
See Example
Usage
- Link to jQuery
- Link to showPassword
$(selector).showPassword(options);
$(selector)
returns the element that triggers the switch when clicked.
Options
options
are:
- attr [string] - default: 'data-showpassword-field'
Trigger's attribute where the password field's selector is stored.
- field [selector,element] - default: null
The password field that showPassword reveals. If set, overrides the attr option.
- clonePrefix [string] - default: 'showPassword-'
The cloned element's name prefix (base name is the password field's name).
- clonePostfix [string] - default: ''
The cloned element's name postfix (base name is the password field's name).
- after [function] - default: function(event, trigger, pwdField, txtField) {}
Function axecuted after the switch has occurred. This is a good place to stop event
's proparation or to change trigger
's text.
- before [function] - default: function(event, trigger, pwdField, txtField) { return true; }
Function executed before the switch. If true
is returned, the switch occurs; otherwise is is cancelled. This is a good place to ask for a confirmation.
Example
$(selector).showPassword({
options1: ...,
options2: ...,
...
});