Skip to content

Commit

Permalink
Merge pull request #710 from Mugunth140/patch-2
Browse files Browse the repository at this point in the history
#564 Solved [BUG] : Email Validation in login page
  • Loading branch information
anuragverma108 authored Oct 19, 2024
2 parents 3116a1e + 40ab327 commit 23787be
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions emailValidator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function validateEmail(email) {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(String(email).toLowerCase());
}
document.addEventListener("DOMContentLoaded", () => {
const form = document.querySelector("form");
form.addEventListener("submit", function(event) {
const emailInput = document.querySelector("input[name='username']");
if (!validateEmail(emailInput.value)) {
alert("Please enter a valid email address.");
event.preventDefault();
}
});
});

0 comments on commit 23787be

Please sign in to comment.