Webflow Forms

Validating Emails

Overview
Webflow Forms Basics
001
Webflow Forms Limitations & Bugs
002
Basic Form Controls
Form Select
051
Form Textarea
052
Customizing Input Controls
Customizing Radio Buttons & Checkboxes
101
Input Number & Decimal Places
102
Numeric Range Sliders
102
Multi-Select Dropdown
104
Auto-Size Textareas
110
Date Pickers
111
Forms Validation
Forms Validation Basics
200
Input Types
201
Using Regex Patterns in Forms Validation
202
Validating Phone Numbers
202
Custom Validation Errors
203
Forms Validation Techniques
Validating Emails
301
Blocking Free Email Provider Addresses
302
Requiring Checkboxes
302
Address Autocomplete
302
Autocomplete / Predictive Input
302
International Phone Numbers
6:50
304
Databinding
Databinding CMS Collections to a Form Select
8:42
401
Forms Validation Techniques
3rd Party Form Handlers
401
Making Forms Dynamic
Displaying Form Parts Conditionally
14:36
501
Multi-Step Forms (MSFs)
501
SPAM Blocking Techniques
Minimizing Form Submission SPAM
600
SPAM Blocking Techniques
CAPTCHA Approaches
601
Form Handlers
3rd Party Form Handlers
901
Integrating the Basin Form Handler
902
Uploading Files
Uploading Files
950
Uploading Files with Uploadcare
951
Uploading Files with Basin
952
No items found.
Published
November 23, 2022
Updated
January 16, 2023
in lightbox

HTML5 has a built-in email input type, and the Webflow designer supports it directly. However, many designers find that browser validation for email address fields is lacking for modern email addresses.

By itself, it will accept this as a valid email;

foo@bar

Why? Well there's a lot of ancient history here, that says that foo@bar is actually a valid email address on internal networks... even though today, on the public Internet, you'd never see an address like that.

So how do we prevent that?

In addition to setting the field type to email, we'll add a pattern attribute to further specify what we consider as valid input.

In Webflow, you do this by selecting the input field and then adding a custom attribute. Here we'll use;

pattern =

^[A-Z0-9a-z._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,64}$

If you have problems with this on any browsers, you can try an even looser match for your pattern;

pattern =

^[\w\-\.]+@([\w\-]+\.)+[\w\-]{2,10}$
IMPORTANT CHANGE
I've updated this recommended pattern due to a Chrome bug that was spotted in the Webflow forum- thanks Carl! Here are some details of the bug.

The original pattern below, which is much more precise and complete, no longer appears to work properly in Chrome.

pattern =

(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

Best Practices

Combine validation techniques, they layer nicely.

In Webflow's designer;

  1. Set the input type to email
  2. Add the custom pattern attribute above to validate your email
  3. Optionally, make the field required
  4. Optionally, improve error messaging. You can add a custom title attribute to describe what is expected.

Demo

See this in action;

Resources

Limitations

Technically, it's possible for email addresses to use non-standard characters, particularly in Internationalized domain names. See discussion here.

Videos
No items found.
Table of Contents
Comments
Did we just make your life better?
Passion drives our long hours and late nights supporting the Webflow community. Click the button to show your love.