To require a valid domain ending in email submissions on Webflow, you'll need to use custom code to handle this validation. Follow these steps to integrate a validation script into your Webflow project.
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector('form');
form.addEventListener('submit', function(event) {
const emailField = form.querySelector('input[type="email"]');
if (emailField) {
const validDomains = ['.com', '.org']; // Define valid domains here
const email = emailField.value;
const domainIsValid = validDomains.some(domain => email.endsWith(domain));
if (!domainIsValid) {
event.preventDefault(); // Prevents form submission
alert('Please provide a valid email address with an approved domain.');
}
}
});
});
</script>
validDomains array to include the domain suffixes you want to allow.
To require a valid domain ending in Webflow form submissions, you embed custom JavaScript into your page's footer code to intercept form submissions and validate email addresses against a list of acceptable domain endings. Make sure to adjust the list of valid domains according to your requirements.