File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,12 +9,12 @@ function getPasswordForgeHTML() {
99 </p>
1010
1111 <input
12- type="text"
12+ type="password"
1313 id="passwordInput"
1414 placeholder="Enter password..."
1515 class="password-input"
1616 >
17-
17+ <button id="togglePasswordBtn" class="toggle-btn">Show</button>
1818 <button id="checkPasswordBtn" class="btn-check">
1919 Check Password
2020 </button>
@@ -44,6 +44,7 @@ function getPasswordForgeHTML() {
4444 margin-top: 1rem;
4545 font-size: 1rem;
4646 background-color: var(--bg-color);
47+ color: #000;
4748 }
4849
4950 .btn-check {
@@ -56,6 +57,16 @@ function getPasswordForgeHTML() {
5657 cursor: pointer;
5758 font-size: 1rem;
5859 }
60+ .toggle-btn {
61+ margin-top: 1rem;
62+ margin-left: 0.5rem;
63+ padding: 0.7rem 1rem;
64+ border: none;
65+ border-radius: 8px;
66+ cursor: pointer;
67+ background: #555;
68+ color: white;
69+ }
5970
6071 .btn-check:hover {
6172 transform: scale(1.05);
@@ -78,6 +89,17 @@ function getPasswordForgeHTML() {
7889
7990function initPasswordForge ( ) {
8091 const checkBtn = document . getElementById ( 'checkPasswordBtn' ) ;
92+ const passwordInput = document . getElementById ( 'passwordInput' ) ;
93+ const toggleBtn = document . getElementById ( 'togglePasswordBtn' ) ;
94+ toggleBtn . addEventListener ( 'click' , ( ) => {
95+ if ( passwordInput . type === 'password' ) {
96+ passwordInput . type = 'text' ;
97+ toggleBtn . textContent = 'Hide' ;
98+ } else {
99+ passwordInput . type = 'password' ;
100+ toggleBtn . textContent = 'Show' ;
101+ }
102+ } ) ;
81103
82104 checkBtn . addEventListener ( 'click' , ( ) => {
83105 const password = document . getElementById ( 'passwordInput' ) . value ;
You can’t perform that action at this time.
0 commit comments