header-logo
Getting started with WixLearn how to build your website and business using Wix.
Creating a websiteDesign and manage your site with smart functionalities.
Account & billingManage subscriptions, plans and invoices.
Using the Wix mobile appsRun your business and connect with members.
Connecting a domainLearn to purchase, connect or transfer a domain to your site.
Managing your businessGet tools to grow your business and web presence.
Promoting your siteBoost your visibility with SEO and marketing tools.
Studio, Partners & EnterpriseGet advanced features to help you work more efficiently.
Need more help?Find solutions, learn about known issues or contact us.
placeholder-preview-image
Wix LearnImprove your skills with our courses and tutorials.
Wix BlogGet tips for web design, marketing and more.
SEO Learning HubLearn to increase organic site traffic from search engines.
Website developmentBuild a custom site using our full-stack platform.
Hire a ProfessionalGet matched with a specialist to help you reach your goals.
placeholder-preview-image
In this article
  • Adding custom validation to your forms
  • Creating a function to verify email addresses
  • FAQs

Wix Forms: Adding Custom Validations to Your Forms

4 min
In this article
  • Adding custom validation to your forms
  • Creating a function to verify email addresses
  • FAQs
Add your own custom validation to verify the info visitors enter before they submit your form. Setting your own rules ensures that the data meets your requirements – some reasons for adding custom validation include:
  • Verifying email addresses and ensuring two fields match.
  • Restricting email address entries to numbers and letters only.
  • Limiting accepted email aliases (e.g. only Gmail).
The first section of this article explains how to build a custom validation, and the second section provides a step-by-step guide for setting up an email address verification.
Important:
This feature is only available for the new Wix Forms
screenshot of wix form, email verification field has fields do not match underneath.

Adding custom validation to your forms

Add custom validation to your forms to control the data that visitors submit. The function uses the form submission data to check if the form passes your defined validation and if not, applies your custom error message. 

To add custom validation to your forms:

  1. Go to Forms & Submissions in your site's dashboard.
  2. Click Edit next to the form you want to update or create a new form.
  3. Click the Settings tab at the top.
  4. Scroll down to Advanced form validations and click Create Validation to open the function builder.
  5. Click Start from Scratch.
  6. Click the Condition step to add parameters to your function using if/else logic.
  7. Set the function's output:
    1. Click the Output step.
    2. Set the validation error, including:
      • (Optional) Form field key: Apply the error message to a specific field. If no field key is added, the error message shows below the submit button. 
      • Error message: Enter the error message shown when the custom validation isn't met. 
    3. Click Add to add the validation error.
    4. (Optional) Click + Add Validation to set another validation error.
    5. Click Apply to save your output.  
  8. Continue creating your function to match your business needs, adding relevant conditions or actions. 
  9. Connect this function to the relevant form:
    1. Click the More Actions icon  at the top right
    2. Select Function configuration.
    3. Click Selected form 1 and then + Select.
    4. Select the relevant form and click OK.
A screenshot of the function configuration dropdown in the function builder.
  1. Enter a name for your function at the top left.
    Tip: It's only visible to you and helps identify the function in the dashboard.
  2. Click Activate at the top right.
screenshot of functions builder, untitled function name is highlighted.
Where can I find my form field key?
Go to the relevant form in the form builder. Click the Advanced tab in the field settings panel. Copy the field key provided and add to the function output.

Creating a function to verify email addresses

One common scenario for creating a custom validation function is to ensure that two email address fields match before allowing a form's submission. The steps outlined below guide you through the process of setting up this particular function.
Before you begin:
Ensure that your form includes two email address fields for validation. To clarify the purpose of the second field to visitors, we suggest renaming the field title to something like 'Confirm your email' or 'Email verification'.

To create a function to verify email addresses:

  1. Go to Forms & Submissions in your site's dashboard.
  2. Click Edit next to the form you want to update or create a new form.
  3. Click the Settings tab at the top.
  4. Scroll down to Advanced form validations and click Create Validation to open the function builder.
  5. Select Validate email address match before submission.
  6. Click Use Template.
screenshot of email validation function set in wix functions
  1. Enter a name for your function at the top left.
    Tip: It's only visible to you and helps identify the function in the dashboard.
  2. Click Activate at the top right.

FAQs

Click a question below to learn more about custom form validations.

Helpmate

Hello

Need a bit more guidance?
Summary of this article
Unlock personalized helpLog in to get the most out of Helpmate.