Hey I used you hack18 about form submissions, but for some reason It’s not working.
I recorded a video about this - Loom | Free Screen & Video Recording Software | Loom
@Support-Luis Any Ideas?
Hey @sepels41! This is an old hack, let me see what I can do.
hey @sepels41! The issue might have come from having multiple forms on the same page. I’ve modified the script into vanilla JS and this should handle both forms on the page.
<script>
document.addEventListener('DOMContentLoaded', function () {
// Make an array of invalid domains
const invalidDomains = ['gmail.com', 'yahoo.com', 'hotmail.com', 'competitor.com'];
// Get all submit buttons and email fields
const submitBtns = document.querySelectorAll('.hack-button');
const emailFields = document.querySelectorAll('.hack18-email');
// Iterate over each submit button
submitBtns.forEach((submitBtn, index) => {
// Add click event listener to each submit button
submitBtn.addEventListener('click', function (event) {
// Get the email field corresponding to the clicked button
const email = emailFields[index];
// Split email at '@' character to get domain
const domainPart = email.value.split('@')[1];
// Check if email is valid
const isValidEmail = invalidDomains.indexOf(domainPart) === -1;
// Log whether email is valid or not (for testing purposes)
if (!isValidEmail) {
// Clear email field
email.value = '';
// Add a 'use business mail' placeholder
email.setAttribute('placeholder', 'Please enter a business email');
// Prevent form submission
event.preventDefault();
}
});
});
});
</script>
I’m not sure what might be happening with the contact form on the modal. This script shouldn’t affect any behavior other than preventing submission if the email is not valid.