Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email validation checker while subscribing #1054

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 deletions contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
/* End at original position */
}
}

.map {
width: 860px;
height: 400px;
Expand Down Expand Up @@ -350,17 +351,50 @@ <h3 style="font-size: 1.5rem; margin-bottom: 10px; color: #2980b9;">Follow Us</h
</div>
</div>

<!-- Newsletter Subscription -->
<!-- Newsletter Subscription -->
<div style="flex: 1; min-width: 200px; margin-bottom: 20px;">
<h3 style="font-size: 1.5rem; margin-bottom: 10px; color: #2980b9;">Subscribe to Our
Newsletter</h3>
<form action="#">
<input type="email" placeholder="Your Email"
<h3 style="font-size: 1.5rem; margin-bottom: 10px; color: #2980b9;">Subscribe to Our Newsletter</h3>
<form id="newsletter-form" action="#">
<input type="email" id="newsletter-email" placeholder="Your Email"
style="padding: 10px; width: 80%; border: none; border-radius: 5px;" required><br><br>
<button type="submit"
style="background-color: #e81a1a; color: white; padding: 10px 20px; border: none; cursor: pointer; border-radius: 5px;">Subscribe</button>
style="background-color: #e81a1a; color: white; padding: 10px 20px; border: none; cursor: pointer; border-radius: 5px;">
Subscribe
</button>
</form>
<div id="subscription-notification" style="display:none; background-color: rgba(212, 237, 218, 0.8); color: #155724; padding: 10px; border-radius: 5px; position: absolute; top: 10px; left: 600px; z-index: 1000; box-shadow: 0 2px 5px rgba(0,0,0,0.3);">
Thank you for subscribing to our newsletter!
</div>

</div>
<script>
document.querySelector("form").addEventListener("submit", function(event) {
event.preventDefault(); // Prevent form from submitting immediately

// Improved Email validation regex to ensure proper domain like "gmail.com"
const emailInput = document.querySelector("input[type='email']");
const emailRegex = /^[^\s@]+@gmail\.com$/;

if (emailRegex.test(emailInput.value)) {
// Show alert notification with green translucent box
const notification = document.getElementById("subscription-notification");
notification.style.display = "block";

// Hide the message after 3 seconds
setTimeout(function() {
notification.style.display = "none";
}, 3000);

// Reset the form
this.reset();
} else {
alert("Please enter a valid Gmail address.");
}
});
</script>


</div>
</div>
<hr>
Expand Down Expand Up @@ -431,5 +465,4 @@ <h3 style="font-size: 1.5rem; margin-bottom: 10px; color: #2980b9;">Subscribe to

</body>


</html>
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ <h2>Contact Us</h2>
</div>
</div>

<!-- FAQ section ends here ... -->
<!-- FAQ section ends here ... -->


<!-- footer start here -->
Expand Down Expand Up @@ -660,7 +660,7 @@ <h2>Follow Us</h2>

</div>
</footer>




Expand Down Expand Up @@ -784,7 +784,7 @@ <h2>Follow Us</h2>




<a href="chatbot.html">
<div class="fixed bottom-0 right-2 chatbot-container">
<button class="chatbot-button group">
Expand Down
29 changes: 29 additions & 0 deletions team.html
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,36 @@ <h3 style="font-size: 1.5rem; margin-bottom: 10px; color: #2980b9;">Subscribe to
<button type="submit"
style="background-color: #e81a1a; color: white; padding: 10px 20px; border: none; cursor: pointer; border-radius: 5px;">Subscribe</button>
</form>
<div id="subscription-notification" style="display:none; background-color: rgba(212, 237, 218, 0.8); color: #155724; padding: 10px; border-radius: 5px; position: absolute; top: 10px; left: 600px; z-index: 1000; box-shadow: 0 2px 5px rgba(0,0,0,0.3);">
Thank you for subscribing to our newsletter!
</div>
</div>
<script>
document.querySelector("form").addEventListener("submit", function(event) {
event.preventDefault(); // Prevent form from submitting immediately

// Improved Email validation regex to ensure proper domain like "gmail.com"
const emailInput = document.querySelector("input[type='email']");
const emailRegex = /^[^\s@]+@gmail\.com$/;

if (emailRegex.test(emailInput.value)) {
// Show alert notification with green translucent box
const notification = document.getElementById("subscription-notification");
notification.style.display = "block";

// Hide the message after 3 seconds
setTimeout(function() {
notification.style.display = "none";
}, 3000);

// Reset the form
this.reset();
} else {
alert("Please enter a valid Gmail address.");
}
});
</script>

</div>
</footer>
<script src="preloader.js"></script>
Expand Down