forked from ANSHIKA-26/WordWise
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ANSHIKA-26#571 from shalini-bhandari/newsletter-up…
…dation Newsletter Updation
- Loading branch information
Showing
2 changed files
with
39 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,40 @@ | ||
document.getElementById('newsletterForm').addEventListener('submit', function(e) { | ||
e.preventDefault(); // Prevent form submission | ||
|
||
// Show success message | ||
const form = document.getElementById('newsletterForm'); | ||
form.classList.add('hide-form'); | ||
|
||
// Show a success message after form hides | ||
const successMessage = document.createElement('div'); | ||
successMessage.classList.add('success-message'); | ||
successMessage.textContent = "Thank you for subscribing!"; | ||
form.parentElement.appendChild(successMessage); | ||
|
||
setTimeout(() => { | ||
e.preventDefault(); // Prevent form submission | ||
|
||
const emailInput = document.getElementById('emailInput'); | ||
const errorMessage = document.getElementById('error-message'); | ||
|
||
// Clear previous error message | ||
errorMessage.style.display = 'none'; | ||
|
||
// Check if '@' is included in the email input | ||
if (!emailInput.value.includes('@')) { | ||
errorMessage.style.display = 'block'; // Show error message | ||
return; // Exit the function if there's an error | ||
} | ||
|
||
// If the email is valid, proceed with hiding the form and showing success messages | ||
const form = document.getElementById('newsletterForm'); | ||
form.classList.add('hide-form'); | ||
|
||
// Show a success message after form hides | ||
const successMessage = document.createElement('div'); | ||
successMessage.classList.add('success-message'); | ||
successMessage.textContent = "Thank you for subscribing!"; | ||
form.parentElement.appendChild(successMessage); | ||
|
||
setTimeout(() => { | ||
successMessage.style.display = 'block'; // Show message | ||
successMessage.style.opacity = '1'; // Fade in effect | ||
}, 500); // Delay for smooth effect | ||
// Show toast notification | ||
const toast = document.getElementById('toast'); | ||
toast.textContent = "Subscription Successful!"; | ||
toast.classList.add('show'); | ||
// Hide toast after 3 seconds | ||
setTimeout(() => { | ||
}, 500); // Delay for smooth effect | ||
|
||
// Show toast notification | ||
const toast = document.getElementById('toast'); | ||
toast.textContent = "Subscription Successful!"; | ||
toast.classList.add('show'); | ||
|
||
// Hide toast after 3 seconds | ||
setTimeout(() => { | ||
toast.classList.remove('show'); | ||
}, 3000); | ||
}); | ||
|
||
}, 3000); | ||
}); |