Form Validation Rules

5 min read

Validation rules ensure that respondents provide complete, correctly formatted data before submitting your form. WittyForm provides a range of built-in validation options plus the ability to create custom rules.

Required Fields

The most common validation rule is marking a field as required. When a field is required, respondents must fill it in before they can submit the form (or advance to the next page on multi-page forms).

To mark a field as required:

  1. Select the field on the canvas.
  2. Toggle the Required switch in the field settings panel.

Required fields display a red asterisk (*) next to the label. If a respondent tries to submit without filling in a required field, an error message appears below the field.

Email Validation

The email field type includes automatic format validation. It checks that the entered value contains a valid email structure (e.g., [email protected]). If the format is invalid, the respondent sees an error message like "Please enter a valid email address."

This validation is built into the field type: no additional configuration is needed. If you want to collect an email, always use the dedicated Email field type instead of a plain text field.

Phone Validation

The phone number field validates that the entered value matches a phone number pattern. It supports international formats and can optionally enforce a specific country format. The field includes a country code selector that automatically adjusts the expected format.

Minimum and Maximum Length

For text fields (short text and long text), you can set character limits:

  • Minimum length: The respondent must enter at least this many characters. Useful for ensuring responses are substantial (e.g., "Please provide at least 50 characters of feedback").
  • Maximum length: The respondent cannot enter more than this many characters. Useful for keeping answers concise or fitting database constraints.

When a maximum length is set, you can optionally display a character counter that shows the respondent how many characters they have remaining.

Numeric limits

For number fields, set minimum and maximum values instead of character counts. For example, set a minimum of 1 and maximum of 100 for an age field, or minimum of 0 for a quantity field.

Regex Patterns

For advanced validation scenarios, you can define a custom regular expression (regex) pattern that the input must match. This is available on text and number fields.

Common regex pattern examples:

  • [A-Z]{2}\d{6}: Matches a format like "AB123456" (e.g., a passport number).
  • \d{5}(-\d{4})?: Matches US zip codes in both 5-digit and 9-digit formats.
  • #[0-9A-Fa-f]{6}: Matches hex color codes like "#FF5733."
  • https?://.*: Matches URLs starting with http or https.

To add a regex pattern, select the field, expand the Validation section in the settings panel, and enter your pattern in the Pattern input. Always provide a clear custom error message that explains what format is expected, since regex errors can be confusing.

Custom Error Messages

Every validation rule in WittyForm comes with a default error message. You can replace these with your own messages to be more specific or match your brand's tone of voice.

To customize an error message, find the Error Message field next to each validation rule in the settings panel. For example:

  • Instead of "This field is required," use "Please tell us your name so we can personalize your experience."
  • Instead of "Invalid format," use "Please enter a valid US phone number (e.g., 555-123-4567)."
  • Instead of "Minimum 50 characters," use "Please share a bit more detail: we need at least 50 characters."

Real-Time Validation

WittyForm validates fields in real time as respondents interact with the form. This means:

  • Errors appear immediately when a respondent finishes typing in a field (on blur) or when they try to move to the next page.
  • Error messages disappear as soon as the respondent corrects their input.
  • The submit button is not disabled: if a respondent clicks it with errors, the form scrolls to the first invalid field and highlights it.

Real-time validation is enabled by default and provides a much better experience than showing all errors only after the respondent attempts to submit.

Selection Field Validation

Selection fields (checkboxes, multi-select) support additional validation rules:

  • Minimum selections: The respondent must choose at least this many options. For example, "Select at least 2 interests."
  • Maximum selections: The respondent cannot choose more than this many options. For example, "Select up to 3 preferences."
  • Exact selections: The respondent must choose exactly this many options.

Validation Best Practices

  • Only mark fields as required if they are truly essential. Every required field adds friction.
  • Write error messages that tell the respondent exactly what to do, not just what is wrong.
  • Use the most specific field type available (email, phone, URL) instead of adding regex validation to a text field.
  • Test all validation rules in preview mode to make sure they work as expected.
  • Keep regex patterns as simple as possible and always pair them with clear error messages.
$37 · paid once

Ready to Build Your Form? Start With Drag and Drop

Start free and keep the five forms for good, or pay once and unlock all of it — unlimited forms, ten team members, AI, CRM, white label and the API. No renewal, ever.

14-day money-backInstant accessNo subscription, ever
Form Validation Rules