What is Field Validation?
Field Validation enables you to add special restrictions or limitations to certain fields on a form, which require the data input by the customer to match the specific conditions you define. The available validation rules vary based on the data type for each field (email fields, number fields, dates fields, etc.), so you can easily make sure you're receiving meaningful data from your customers when they fill out a form.
How do I add validation for a field?
To get started with field validation, simply click on any field in the form builder to open the 'Edit field' panel. You can then scroll down to the 'Validation' section:
Important note: Make sure you type in an error message when setting up field validation, otherwise the validation will be ignored!
Types of field validation
Set field as 'required'
Almost every field type has a setting you can enable to make a field required. You can also edit the error message for each field which will show if a customer does not supply a value.
Field-specific validation rules
There are some global validation rules that work across multiple field types, however, some fields offer special validation rules that are not applicable to other fields due to the type of data being collected. Below you'll find some quick insights into the rules available for certain types of fields:
Text fields
Must equal x
Must contain x
Must be longer than x characters
Must match regular expression
and more!
Email fields
Must be a valid email address
Domain must equal
Domain must not equal
Number fields
Greater than/Less than
Must equal/Must not equal
Greater than or equal to/Less than or equal to
Date fields
Must be more than X years ago
Must be less than X days from now
Must be before [date]
Must be on or after [date]
and more!
File upload fields
[File size] must be larger than/smaller than
Extension must be (use comma separation to allow multiple types)
Checkbox (True/False) fields
Must be true
Must be false
Special cases
Password & Password confirmation fields
Password fields must always be at least 5 characters as this is the standard that Shopify has set. However, you can increase the number of characters required or you can add extra validation rules to require stronger passwords.
Please note that field validation is disabled for password confirmation fields, since the value must always match the "Password" field.
Form rules
If you want to make a field optionally required based on other criteria, you can do so using form rules.
Are we missing something?
If you have an idea for field validation that we're currently missing, please let us know!