Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://www.gravityhelp.com/forums/topic/password-advanced-field-enable-password-strength-and-minimum-strength#post-182157
- // from Gravity Forms version 1.6.12
- // wp-content/plugins/gravityforms/js/gravityforms.js starting on line 514
- //
- // Password strength meter
- function gformPasswordStrength(password1, password2) {
- var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, mismatch = 5, symbolSize = 0, natLog, score;
- if(password1.length <=0)
- return "blank";
- // password 1 != password 2
- if ( (password1 != password2) && password2.length > 0)
- return "mismatch";
- //password < 4
- if ( password1.length < 4 )
- return "short";
- if ( password1.match(/[0-9]/) )
- symbolSize +=10;
- if ( password1.match(/[a-z]/) )
- symbolSize +=26;
- if ( password1.match(/[A-Z]/) )
- symbolSize +=26;
- if ( password1.match(/[^a-zA-Z0-9]/) )
- symbolSize +=31;
- natLog = Math.log( Math.pow(symbolSize, password1.length) );
- score = natLog / Math.LN2;
- if (score < 40 )
- return "bad";
- if (score < 56 )
- return "good";
- return "strong";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement