jQuery password strength plugin callback validation method
- by jmorhardt
I'm using a a jQuery plugin to evaluate password strength. It gives a graphical representation for the user to see how secure the password is. I'd like to use it to validate the field as well.
The plugin works by assessing the password and giving it a score. I want to be able to verify that the user has entered a password of at least a certain score. The code is hosted on jQuery's site here: http://plugins.jquery.com/project/pstrength.
The documentation states that there is a way to add a rule and do custom validation. I'm not sure where to start. The inline documentation states:
* === Changelog ===
* Version 2.1 (18/05/2008)
* Added a jQuery method to add a new rule: jQuery('input[@type=password]').pstrength.addRule(name, method, score, active)
And later in the code there's this method:
jQuery.extend(jQuery.fn.pstrength, {
'addRule': function (name, method, score, active) {
digitalspaghetti.password.addRule(name, method, score, active);
return true;
},
'changeScore': function (rule, score) {
digitalspaghetti.password.ruleScores[rule] = score;
return true;
},
'ruleActive': function (rule, active) {
digitalspaghetti.password.rules[rule] = active;
return true;
}
});
If anybody has seen an example of how to do this I'd appreciate a pointer in the right direction. Thanks!