Download
Basic usage
$( 'input' ).passy(function( strength, valid ) {
// Set color basd on validness and strength
if( valid ) {
if( strength < $.passy.strength.HIGH ) {
color = 'orange';
} else {
color = 'green';
}
} else {
color = 'red';
}
$( this ).css( 'background-color', color );
});
Configuration
Before calling .passy()
, you can alter these settings:
// Requirements a inserted password should meet
$.passy.requirements = {
// Character types a password should contain
characters: [
$.passy.character.DIGIT,
$.passy.character.LOWERCASE,
$.passy.character.UPPERCASE,
$.passy.character.PUNCTUATION
],
// A minimum and maximum length
length: {
min: 8,
max: Infinity
}
};
// Thresholds are numeric values representing
// the estimated amount of days for a single computer
// to brute force the password, assuming it processes
// about 1,000,000 passwords per second
$.passy.threshold = {
medium: 365,
high: Math.pow( 365, 2 ),
extreme: Math.pow( 365, 5 )
};
Methods
Generate a password of a specific length:
$( 'input' ).passy( 'generate', 16 );
Check if a field’s content is valid:
if(
$( 'input' ).passy( 'valid' )
) { ... }