Skip to content

Commit

Permalink
Fixed signup even on lower password strength
Browse files Browse the repository at this point in the history
  • Loading branch information
jvkousthub committed Oct 22, 2024
1 parent 9c39a26 commit 81b7aa3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 5 additions & 5 deletions signup/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ <h2>Create an Account</h2>
<label>Password</label>
<div id="password-strength"></div>
<div id="password-requirements">
<p id="length-requirement">At least 6 characters</p>
<p id="uppercase-requirement">At least one uppercase letter</p>
<p id="number-requirement">At least one number</p>
<p id="special-requirement">At least one special character</p>
<p id="length-requirement">✔️ At least 6 characters</p>
<p id="uppercase-requirement">✔️ At least one uppercase letter</p>
<p id="number-requirement">✔️ At least one number</p>
<p id="special-requirement">✔️ At least one special character</p>
</div>
</div>
<button class="signup-btn" type="submit">Sign Up</button>
<button class="signup-btn" type="submit" disabled>Sign Up</button>
<div class="extra-links">
<button class="home-btn"><i class="fas fa-home"></i><a href="../index.html">Home</a></button>
<button class="login-btn"><i class="fas fa-sign-in-alt"></i><a href="../login/login.html">Login</a></button>
Expand Down
5 changes: 4 additions & 1 deletion signup/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ card.addEventListener("mouseleave", function () {
card.style.transform = "perspective(1000px)";
});


document.querySelector(".signup-form").addEventListener("submit", function (e) {
e.preventDefault(); // Prevent form submission

Expand Down Expand Up @@ -83,6 +82,7 @@ document.getElementById('password').addEventListener('input', function() {
const uppercaseRequirement = document.getElementById('uppercase-requirement');
const numberRequirement = document.getElementById('number-requirement');
const specialRequirement = document.getElementById('special-requirement');
const signupButton = document.querySelector('.signup-btn');
let strength = '';
let strengthClass = '';

Expand Down Expand Up @@ -119,4 +119,7 @@ document.getElementById('password').addEventListener('input', function() {
strengthDiv.textContent = strength;
strengthDiv.className = strengthClass;
this.className = strengthClass;

// Enable/disable signup button
signupButton.disabled = strength !== 'Strong';
});

0 comments on commit 81b7aa3

Please sign in to comment.