Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the password validation feature #278

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ <h2>Create Your Account</h2>
<form id="signupForm" action="#" method="POST">
<input type="text" placeholder="Full Name" required>
<input type="email" placeholder="Email Address" required>
<input type="password" placeholder="Password" required>
<input type="password" placeholder="Confirm Password" required>

<input type="password" id="password" name="password" placeholder="Password" required>
<input type="password" id="confirmPassword" name="confirmPassword" placeholder="Confirm Password" required>

<button type="submit">Sign Up</button>
</form>
<button class="login-btn" onclick="window.location.href='login.html'">Go to Login</button>
Expand All @@ -149,7 +151,27 @@ <h2>Create Your Account</h2>
event.preventDefault();

var formData = new FormData(this);

var password = formData.get('password');
var confirmPassword = formData.get('confirmPassword');

function isStrongPassword(password) {
const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&#])[A-Za-z\d@$!%*?&#]{8,}$/;
return regex.test(password);
}

// Password match validation
if (password !== confirmPassword) {
alert('Passwords do not match.');
return;
}

// Password strength validation
if (!isStrongPassword(password)) {
alert('Password must be at least 8 characters long, include an uppercase letter, a lowercase letter, a number, and a special character.');
return;
}

fetch('signup-process.php', {
method: 'POST',
body: formData
Expand Down