Skip to content

Commit

Permalink
Validated the signup form
Browse files Browse the repository at this point in the history
  • Loading branch information
shriyadindi committed Oct 23, 2024
1 parent d393add commit d9e6b37
Showing 1 changed file with 32 additions and 1 deletion.
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

0 comments on commit d9e6b37

Please sign in to comment.