1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
<title>Lazr-js examples: passwordmeter</title>
5
<link rel="stylesheet" type="text/css" href="../../build/cssreset/reset-min.css"></link>
6
<link rel="stylesheet" type="text/css" href="../../build/cssfonts/fonts-min.css"></link>
7
<link rel="stylesheet" type="text/css" href="../../build/cssbase/base-min.css"></link>
9
<script type="text/javascript" src="../../build/yui/yui-debug.js"></script>
10
<script type="text/javascript" src="../../build/lazr/lazr-meta.js"></script>
11
<script type="text/javascript">
12
var LAZR_YUI_CONFIG = {
15
modules: LAZR_MODULES,
16
insertBefore: "style-overrides",
19
var LP = YUI(LAZR_YUI_CONFIG);
20
var demo_strengthFunc = function(password){
21
var strength = password.length * 10;
57
LP.use('node', 'event', 'lazr.passwordmeter', function(Y){
59
var passwordMeter = new Y.PasswordMeter({
60
input: '#demo_password',
61
contentBox: '#demo_meter',
62
func: demo_strengthFunc
65
passwordMeter.render();
68
<style id="style-overrides" type="text/css">
86
<h1>A Password Strength Meter Widget</h1>
87
<h2>Demonstration</h2>
88
<label for="demo_password">
92
<input type="password" id="demo_password" />
93
<div id="demo_meter"> </div>
99
<h3>CSS and Javascript</h3>
100
Add the following css and javascript tags into your page.
102
<link rel="stylesheet" href="../../build/cssreset/reset-min.css" />
103
<link rel="stylesheet" href="../../build/cssfonts/fonts-min.css" />
104
<link rel="stylesheet" href="../../build/lazrjs/cssbase/base-min.css" />
105
<script type="text/javascript" src="../../build/yui/yui-min.js"></script>
106
<script type="text/javascript" src="../../build/lazr-meta.js">lt;/script>
109
In order to facilitate ease of integration into existing web pages with differing needs in both layout and
110
password strength requirements, the widget takes as construction parameters the ids of the password field to
111
be evaluated, the id of the dom element that will hold the meter, and a reference to a javascript function that will
112
be used to evaluate the strength of the password.
114
<label for="password">Password<label>
116
<input type="password" id="password" />
117
<div id="meter"><div>
122
<h2>Widget Setup</h2>
124
The javascript function that will be used by the widget will recive one parameter: the password as a string.
125
The function needs to return an object literal with two attributes: color and text. The return value should
126
look something like this:
128
var strengthFunc = function(password) {
129
//whatever logic you require to determine password strength
131
"color": [an html color code like '#FF0000'],
132
"text": [a description like "weak" or "strong"]
137
Finally, putting it all together the widget needs to be constructed and rendered as follows:
140
var LAZR_YUI_CONFIG = {
142
base: "../../build/",
143
modules: LAZR_MODULES,
144
insertBefore: "style-overrides",
146
LP.use('node', 'event', 'lazr.passwordmeter', function(Y){
148
var passwordMeter = new Y.PasswordMeter({
150
contentBox: '#meter',
154
passwordMeter.render();