Building forms
Checking answers
Required fields, lengths, numbers, patterns, unique answers, dates, available hours, choices, matching fields, and the messages visitors see.
Each field's Validation settings decide which answers it accepts. The browser checks them as the visitor fills in the form, and the server checks them again when it is sent, so the rules hold even without JavaScript or when someone sends data directly. The same checks run when staff edit an entry and when entries are imported from a CSV file.
Common rules
| Field | Rules |
|---|---|
| Every field | Required; Who sees this field (see Conditional logic) |
| Text and paragraph | Minimum and maximum length or number of words, allowed characters (letters, digits and so on), a pattern, an input mask, accepted or refused values |
| Ask for the address twice, accept or refuse domains, check that the domain can receive email | |
| Web address | Require https, accept or refuse sites |
| Number and slider | Minimum, maximum, step and decimal places |
| Telephone | Countries offered, number length for the country |
| Date | Earliest and latest date (fixed or relative to today), days of the week and dates that cannot be chosen, minimum and maximum age, a gap after another date |
| Time | Earliest and latest time, times that cannot be chosen, available hours by day |
| Choices | Minimum and maximum number of choices |
| File upload | Number of files, size and file types (see File uploads) |
| Repeating group | Minimum and maximum number of rows |
Numbers: including or excluding the limits
By default the minimum and maximum are allowed answers. Turn on The minimum itself is not accepted or The maximum itself is not accepted for rules such as "more than 0" or "less than 100". The message then says "greater than" or "less than".
Patterns
Must match a pattern takes a regular expression. Common patterns offers ready ones, so you do not need to write your own:
- Whole number, for example -12 or 40
- Letters and digits without spaces
- User name: 3 to 20 letters, digits or underscores
- Reference like AB-12345
- UK postcode, US ZIP code, Canadian postal code, postal code of 4 to 6 digits
- IBAN (format only, not the check digits)
- Colour in hex, for example #1f6feb
Choose Custom pattern to write your own. A pattern with a mistake is marked in the builder and ignored rather than blocking every answer. Reject values that match instead turns the rule around, and Pattern message sets the text visitors see. Developers can add presets with the flvf_pattern_presets filter.
Unique answers
Must be unique across entries of this form refuses an answer that an earlier entry already used, for example a membership number. Letter case is ignored unless you turn on Upper and lower case count as different. Unique together with (a date, dropdown or single choice field) checks a pair, for example one booking per email address for each event date.
Available hours
For a time field, Available hours lists the times that can be chosen, for example 09:00 to 12:30 and 13:30 to 17:00. Each set of hours can apply to chosen days of the week; a set without days applies every day. With Date that decides the day, the hours follow the day chosen in a date field, so Saturday can have shorter hours than Monday. On a day without hours, the visitor is asked to choose another day.
Show the available hours under the field (on by default) prints them as a hint, for example "Available: Monday to Friday 09:00 to 17:00; Saturday 10:00 to 13:00."
Matching another field
Must match another field asks for the same answer twice, for example a confirmation of an account number. Email fields have their own Ask for the address twice.
Messages
Every rule has a clear built in message in the form's language, such as "Please enter 10 or less." Change the required message for the whole form in its General settings (Default required message) or for one field in its Messages settings; patterns have their own Pattern message. Developers can change any built in message with the flvf_messages filter.
When sending fails, List problems when sending fails (on by default) shows a list of every problem with a link to each field and moves focus to it. Problem list position puts it at the top of the form or under the buttons, and Problem list icon chooses its icon.