Do you want to block non-business emails from your Webflow forms, such as Gmail, Yahoo or Hotmail? You can create a list of domain names to block.
Block non-business emails with Finsweet, in 3 steps
Finsweet offers "Hack #18" to do this. The principle is simple. It adds JavaScript code to your page that blocks non-business emails.
Step 1, copy and paste the code
Copy and paste the JavaScript code below into the before </body> tag area of the page on your Webflow site that contains the form.
Step 2, choose the addresses to block
Now choose the domains to block, for example Gmail, Yahoo or Hotmail.
In the line const invalidDomains = ['AJOUTER-ICI'], replace the value "AJOUTER-ICI" with the domain name you want to block.
To block Google addresses, for example, replace "AJOUTER-ICI" with "gmail.com". Do the same for the other domains.
Step 3, identify the form elements
The JavaScript code now needs to recognize the submit button and the field where users enter their email address on the form page.
To do this, proceed as follows:
- Add the CSS class
.hack-buttonto your form's submit button. - Add the class
.hack18-emailto your form's email field.
You're done. You now know how to block non-business emails from your Webflow forms.