File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
phpmyfaq/assets/src/utils Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -36,19 +36,29 @@ export const handlePasswordStrength = () => {
3636
3737 if ( password && strength ) {
3838 password . addEventListener ( 'keyup' , ( ) => {
39- strength . style . width = ( passwordStrength ( password . value ) * 25 ) . toString ( ) + '%' ;
39+ const strengthValue = passwordStrength ( password . value ) * 25 ;
40+ strength . style . width = strengthValue . toString ( ) + '%' ;
41+ strength . classList . remove ( 'bg-danger' , 'bg-warning' , 'bg-success' ) ;
42+
43+ if ( strengthValue < 75 ) {
44+ strength . classList . add ( 'bg-danger' ) ;
45+ } else if ( strengthValue < 90 ) {
46+ strength . classList . add ( 'bg-warning' ) ;
47+ } else {
48+ strength . classList . add ( 'bg-success' ) ;
49+ }
4050 } ) ;
4151 }
4252} ;
4353
4454/**
4555 * Rules for the password strength calculation:
46- * - at least 8 characters
47- * - bonus if longer
48- * - a lower letter
49- * - an upper letter
50- * - a digit
51- * - a special character
56+ * - at least eight characters
57+ * - bonus if longer
58+ * - a lower letter
59+ * - an upper letter
60+ * - a digit
61+ * - a special character
5262 *
5363 * @param password
5464 * @returns {number }
You can’t perform that action at this time.
0 commit comments