Custom Validations

Forms

Validate a form using regular expressions and code validations.

Play with the example below to see what you can do:

Open this example as a template so you can see how everything works in the Editor. 

This example demonstrates how forms can be validated using regular expressions and the custom validations API.

The phone input is validated using the regex:

^\([0-9]{3}\) [0-9]{3}-[0-9]{4}$

which checks that the phone number is in the format:

(555) 555-5555

The Email and Confirm Your Email inputs are validated in code, using the onCustomValidation function to register a validation event handler. It runs when the element's validation is checked. Here we check that both the email and confirmation email match.

 

When the user clicks the Done button, before saving the data in the reservations collection, we use a dataset onBeforeSave event handler to check if all the field values are valid. If they are not, we display relevant error messages in a text element which expands at the bottom of the form.

Next Steps

  1. Open this example in the Editor to work with the template.

  2. Publish the site.

  3. Learn how to work with examples in Corvid.

Example Code

arrow&v

Example Demonstrates

Input Validation

Dataset Hooks

Regular Expressions

To start using Corvid:  Go to the Wix Editor > Dev Mode > Turn on Dev Mode