Webflow Forms

Validating Phone Numbers

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
March 25, 2024
Updated
in lightbox

By comparison with email addresses, phone number are much more difficult to format-validate, particularly when you need to support various international phone number formats.

Approaches

Input Type

Webflow supports the Phone input type, which generates the input as type=tel, however it only offers very general validations.

Regex and HTML field constraints

You can use custom attributes to constrain input features, e.g. for a UK number;

  • pattern = *(0-9)*
  • maxlength = 11
  • minlength = 11
This approach can be combined with the Input type = Phone.

3rd Party Validation Libs

Libphonenumber

Open source project which appears to have been taken over by Google;

https://libphonenumbers.js.org/docs/

https://github.com/google/libphonenumber

DEMO - https://htmlpreview.github.io/?https://github.com/google/libphonenumber/blob/master/javascript/i18n/phonenumbers/demo-compiled.html

Add the library;

Configure your code for your element;

Also supports a special mode for an AsYouTypeFormatter.

https://libphonenumbers.js.org/docs/inputDigit

3rd Party Service API

If you want deeper validation, to ensure that a number is actually registered and to know what carrier handles it, you can use a service like Veriphone.

https://veriphone.io/

Examples

Treat these as starting points as they have not been thoroughly tested.

For all of these, set the input field type to Phone ( tel ).

US Format Number Validation

  • pattern = \d{3}[-]\d{3}[-]\d{4}
  • title = US phone number (format: 123-456-7890)

Mexico

  • pattern = 01[-]\d{3}[-]\d{3}[-]\d{4}
  • title = Mexican phone number (format: 01-123-456-7890)

Germany

  • pattern = \+49 \d{4} \d{6}
  • title = German phone number (format: +49 1234 567890)

UK

  • pattern = \+44 \d{4} \d{6}
  • title = UK phone number (format: +44 1234 567890)

Notes

https://discourse.webflow.com/t/phone-number-input-validation-redux/62455/9

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.