Skip to content

Commit

Permalink
Merge pull request #435 from nidhipai78/email
Browse files Browse the repository at this point in the history
Message added on successful subscription #434
  • Loading branch information
piyushg-07 authored Jun 8, 2024
2 parents 7e4db80 + 92c232b commit d8a7833
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,35 @@
</div>
<div class="newsletter">
<div class="footer_titles">Subscribe to our newsletter</div>
<form>
<input type="text" id="emailId" name="email" placeholder="Your Email">
<button type="submit">Subscribe</button>
<form id="subscriptionForm">
<input type="email" id="emailId" name="email" placeholder="Your Email" required>
<button type="submit">Subscribe</button>
</form>
<div id="subscriptionMessage" style="display: none;">You have subscribed successfully!</div>
</div>

<script>
document.getElementById("subscriptionForm").addEventListener("submit", function(event) {
event.preventDefault(); // Prevent the form from submitting

// Get the email input value
var email = document.getElementById("emailId").value;

// Email validation using regular expression
var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email)) {
alert("Please enter a valid email address.");
return;
}

// Simulate subscription (you may replace this with actual subscription code)
// For now, just displaying the success message
document.getElementById("subscriptionMessage").style.display = "block";
});
</script>



<div class="contact">
<div class="footer_titles">Contact Us</div>
<a href="mailto:[email protected]"><div class="mail">[email protected]</div></a>
Expand Down

0 comments on commit d8a7833

Please sign in to comment.