header-logo
Getting started with WixBuild your website and business with Wix. Try using our AI tools to create your website, customize templates, or hire professionals to build or enhance your online presence.
Creating a websiteRead how to use the Wix Editor and manage content on your site. Discover how to protect your visitors' privacy and make your site accessible.
Account & billingReview your account settings, manage your subscriptions and plans and understand your invoices.
Using the Wix mobile appsUse our mobile apps to run your business efficiently on the go and set up a dedicated app for your site members to stay in touch.
Connecting a domainFollow our step-by step guides to learn how to purchase, connect or transfer a domain for your site, and find out how to keep your site’s data secure.
Managing your businessGet tools to grow your business and web presence. Find the right tools for your specific needs, set up online payments and keep track of your site's analytics.
Promoting your siteLearn to make your site more visible promoting it on search engines, sending emails and running paid ads. Improve your online presence with practical tips.
Studio, Partners & EnterpriseGet the most out of your Studio or Enterprise account with advanced features that'll help you work more efficiently.
Need more help?Find solutions for site performance and technical issues, learn about issues we’re working to fix or contact us for help.
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

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?
Unlock personalized helpLog in to get the most out of Helpmate.