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

Validated the signup form #714

Closed
wants to merge 1 commit into from
Closed
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
33 changes: 32 additions & 1 deletion Html-files/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,38 @@ <h1 style="font-family: var(--ff-philosopher);color: hsl(203, 30%, 26%);">SIGN U
defer>
</script>
<script>
// JavaScript to toggle password visibility
document.querySelector('.btn-login').addEventListener('click', function(event) {
event.preventDefault(); // Prevent form default submission
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;

// Simple form validation
if (!name || !email || !password) {
alert('Please fill out all fields.');
} else {
console.log({ name, email, password });
// Implement form submission logic here
}
});
if (usernameInput.value.trim() === "") {
usernameError.textContent = "Username is required.";
usernameError.style.display = "block";
valid = false;
} else {
usernameError.style.display = "none";
}

// Validate email with a regular expression
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailPattern.test(emailInput.value)) {
emailError.textContent = "Please enter a valid email address.";
emailError.style.display = "block";
valid = false;
} else {
emailError.style.display = "none";
}
// JavaScript to toggle password visibility
const passwordField = document.getElementById('password');
const showPasswordCheckbox = document.getElementById('showPassword');

Expand Down