Skip to content

Commit

Permalink
Merge pull request #409 from Cgarg9/main
Browse files Browse the repository at this point in the history
Email format validation added
  • Loading branch information
swaraj-das authored Oct 15, 2024
2 parents 09cc963 + 040d940 commit 57addb2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions SignUp/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ document.addEventListener("DOMContentLoaded", () => {
alert("Every field is required");
return;
}

const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
if (!emailPattern.test(email)) {
alert("Please enter a valid email address.");
return; // Stop the function if the email is not in the right format
}

const userdata = {
name,
Expand Down
7 changes: 7 additions & 0 deletions login/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ <h1>Login to Your Account</h1>

const email = document.querySelector("#gmail").value;
const password = document.querySelector("#password").value;

const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
if (!emailPattern.test(email)) {
alert("Please enter a valid email address.");
return; // Stop the function if email is not in the right format
}

const userData = {
email,
password
Expand Down

0 comments on commit 57addb2

Please sign in to comment.