+ match_error: "$name must contain both a letter and a number.",
+ custom_js: function (args) {
+ var v = args.value;
+ var n = 0;
+ if (v.match(/[a-z]/)) n++;
+ if (v.match(/[A-Z]/)) n++;
+ if (v.match(/[0-9]/)) n++;
+ var sym = v.match(/[ ~!@#$%^&*()_,.?{}\[\]]/) ? 1 : 0;
+ var s = (! v.length) ? ''
+ : (v.length < 6) ? 'weak'
+ : (v.length < 7) ? (sym || n == 3) ? 'ok' : 'weak'
+ : (v.length < 10) ? (n < 3 && ! sym) ? 'ok' : 'good'
+ : sym ? 'excellent' : 'good';
+ document.getElementById('password_strength').innerHTML = s;
+ if (s === 'weak') throw "Cannot use a weak password. Try increasing the length or adding variation.";
+ return 1;
+ }