top of page

Managing your business

Managing your customers

Wix Forms: Adding Custom Validations to Your Forms


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

      Wix Forms: Adding Custom Validations to Your Forms

      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.


Wix Forms: Adding Custom Validations to Your Forms


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'.


Wix Forms: Adding Custom Validations to Your Forms

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.


If you already customized a form in the form builder and want to build a custom validation for that specific form, you can quickly access the functions builder from the Settings tab.

Wix Forms: Adding Custom Validations to Your Forms

Yes. You can test your form validation on your live site.


Need An AI Run Website?
Contact Us
 Today!

wix experts
Graphic2Traffic web design
©
bottom of page