Skip to content

Commit

Permalink
Merge pull request #53 from AbhineshJha/Contactformfixin
Browse files Browse the repository at this point in the history
Fixed the contact Gmail input section
  • Loading branch information
jaysomani authored Jan 11, 2024
2 parents 586ef51 + be17a85 commit 8f455cc
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions pages/contact/contact.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
const sendLetter = document.getElementById("sendLetter");
const emailInput = document.getElementById("emailInput");

function addClass(event) {
event.preventDefault(); // Prevents the default form submission behavior

function addClass() {
// Validate email format
const emailValue = emailInput.value.trim();
if (!isValidEmail(emailValue)) {
alert("Invalid email address");
return;
}

// Add the "sent" class if the email is valid
document.body.classList.add("sent");


}

function isValidEmail(email) {
// Regular expression for a simple email validation
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
}

sendLetter.addEventListener("click", addClass);
sendLetter.addEventListener("click", addClass);

0 comments on commit 8f455cc

Please sign in to comment.