/weakling

Weakling is a simple prototype-based javascript plugin to measure the strength of a password

Primary LanguageRubyMIT LicenseMIT

Weakling

Weakling is a simple prototype-based javascript plugin to measure the strength of a password.

I significantly modified Frane’s plugin called password_strength_meter
I didn’t want a percentage bar so I stripped that out, I refactored the helper to be more readable. It passes a hash instead of array for strength text Its supports locales.

Requires

Prototype

Installation and Usage

Download Plugin

./script/plugin install git://github.com/omenking/weakling.git

Add Locales

Then add this to your config/locales/en.yml

weakling:
default: Must be at least 5 characters
error: too short
weak: weak
average: average
strong: strong

the Add Javascript and Stylesheets

Go get em and place them in your public/javascripts

Prototype

The add into your layout head

<%= javascript_include_tag ‘prototype’, ‘weakling’ >
<
= stylesheet_link_tag ‘weakling.css’ %>

Add the password_strength function below in your password field in your form

<%= f.password_field :password >
<
= password_strength :password_strength, ‘user_password’ %>

Digest It

password_strength(name,target,options={})

  • name – id of the password_strength
  • target – id of the password_field

Sass and Sprockets

If you have Sass or Sprockets installed it’ll copy them to their respected default directories.
Sass and Sprockets rule!

Remember to add to your app/javascripts/application.js

//= require

Remember to add to your application.sass

@import weakling.sass

Copyright © 2009 Andrew Brown, released under the MIT license