@@ -44,7 +44,7 @@ function getPasswordForgeHTML() {
4444 margin-top: 1rem;
4545 font-size: 1rem;
4646 background-color: var(--bg-color);
47- color: #000 ;
47+ color: var(--text-color) ;
4848 }
4949
5050 .btn-check {
@@ -110,14 +110,26 @@ function initPasswordForge() {
110110 }
111111 } ) ;
112112
113+ const rulesContainer = document . getElementById ( 'rulesContainer' ) ;
114+ const result = document . getElementById ( 'passwordResult' ) ;
115+
116+ function checkRules ( ) {
117+ const password = passwordInput . value ;
113118 checkBtn . addEventListener ( 'click' , ( ) => {
114119 const password = passwordInput . value ;
115120
116121 // 1. Evaluate Booleans
117122 const hasLength = password . length >= 8 ;
118123 const hasNumber = / \d / . test ( password ) ;
119124 const hasUpper = / [ A - Z ] / . test ( password ) ;
120- const hasSpecial = / [ ! @ # $ % ^ & * ] / . test ( password ) ;
125+ const hasSpecial = / [ ! @ # $ % ^ & * ( ) _ + \- = \[ \] { } ; ' : " \\ | , . < > \/ ? ~ ` ] / . test ( password ) ;
126+
127+ rulesContainer . innerHTML = `
128+ <p>${ hasLength ? '✅' : '❌' } Must contain at least 8 characters</p>
129+ <p>${ hasNumber ? '✅' : '❌' } Must contain a number</p>
130+ <p>${ hasUpper ? '✅' : '❌' } Must contain an uppercase letter</p>
131+ <p>${ hasSpecial ? '✅' : '❌' } Must contain a special character</p>
132+ ` ;
121133
122134 // 2. Update Individual Rule UI
123135 ruleLength . textContent = hasLength ? '✅ Must contain at least 8 characters' : '❌ Must contain at least 8 characters' ;
@@ -134,4 +146,4 @@ function initPasswordForge() {
134146 result . style . color = 'red' ;
135147 }
136148 } ) ;
137- }
149+ }
0 commit comments