🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!

Gravity Forms Cross-Field Validation Rules Setup Guide

Updated 12 min read Gravity Forms Fields & Inputs
On this page
  1. Video walkthrough
  2. What you need
  3. Install and activate
  4. How it differs from other kinds of validation
  5. The Validation Rules tab
  6. Write a rule
  7. Offsets
  8. Fixed values
  9. Rule types and comparisons
  10. Dates
  11. Times
  12. Date + time
  13. Numbers, prices and totals
  14. Text
  15. A group of fields
  16. Conditions
  17. Empty and hidden fields
  18. What visitors see
  19. Multi-page forms
  20. Examples
  21. How the checks work
  22. Privacy and performance
  23. Troubleshooting

Video walkthrough

Gravity Forms Cross-Field Validation Setup Guide: Compare Dates, Times, Numbers & Field Groups
Video setup guide: Gravity Forms Cross-Field Validation Watch on YouTube

The Gravity Forms Cross-Field Validation Rules add-on checks whether the answers in a form make sense together. A rule compares one field with another field, with a fixed value or with today or now: the return date must be after the departure date, the drop-off time later than the pick-up time, the maximum budget at least the minimum, the shares must add up to 100, at least one phone number must be given. Each rule has its own error message on the field you choose. Rules are checked live in the browser and always again on the server. This guide covers installing the add-on, writing rules, every rule type and operator, conditions, empty and hidden fields, multi-page forms and how the checks work.

What you need

You need Gravity Forms 2.9 or newer and WordPress 6.5 or newer on PHP 7.4 or newer. The add-on adds a tab to the form settings; there is nothing to install on the server and no code to write. It makes no outside connection beyond checking gravityextra.com for your licence and plugin updates.

Editing rules needs the Gravity Forms edit forms capability, the same permission that lets someone change the form itself.

Install and activate

  • Upload the add-on zip in Plugins → Add New → Upload Plugin and activate it.
  • Go to Forms → Settings → Validation Rules, enter your GravityExtra licence key and press Activate License.
  • Open any form and choose Settings → Validation Rules to add its rules.

Without an active licence the tab only shows a note with a link to the licence settings, and the rules are not checked: forms behave exactly as they would without the add-on. Your saved rules are kept and start working again as soon as the licence is active.

How it differs from other kinds of validation

It helps to know what each kind of validation can and cannot do, so you pick the right tool for each check.

  • Gravity Forms itself validates each field on its own: required fields, a valid e-mail address or date, a number inside the range set on that field, no duplicate values. It has no setting that compares one field with another, so a return date before the departure date passes because each date is valid on its own.
  • Our Live Field Validation add-on shows those per-field checks while the visitor types, instead of after the form is sent. It checks each field against its own rules and does not compare fields with each other. The two add-ons work well together: one gives instant feedback on single fields, the other adds the rules between fields.
  • Pattern (regular expression) validation, which several free plugins add, checks that one field matches a pattern, for example a postcode or an order number format. It looks at one value at a time and cannot say that one date must come after another or that three fields must add up to 100.
  • Cross-Field Validation Rules compares fields with each other, with fixed values and with the current date and time, checks groups of fields, and does it live in the browser and again on the server.

The Validation Rules tab

The Validation Rules tab of a form: a list of rules, each comparing fields with its own error message and the field that shows it
The Validation Rules tab: every rule of the form, each with its message and the field that shows it.

Open a form, then Settings → Validation Rules. The tab lists the rules of this form in the order they are checked. Press + Add rule to add one, change any setting in place, untick Enabled to switch a rule off without deleting it, and press Remove to delete it. Nothing is stored until you press Save rules. When you save, every rule is checked again on the server: a rule that points to a field that no longer exists, or that misses a field or value, is not saved, and the editor warns you before it happens.

A form can have up to 100 rules. Rules belong to the form, so they are copied when you duplicate the form and exported with it.

Write a rule

One rule in the editor: Return date is after Departure date, the error message, the field that shows it and the condition Trip type is Return
One rule: Return date is after Departure date, with its message, the error field and a condition.

Every rule has the same parts:

  • Compare — what kind of values the rule compares: dates, times, date + time (two fields), numbers (including prices and totals), text, or a group of fields.
  • Check that — the left side: usually a field, but a date rule can also start from Today, a time rule from Now and a number rule from the Order total.
  • The comparison — for example is after, is less than or equal to or is the same as. The full lists are below.
  • The right side — another field, a fixed value, today, now or the order total, plus an optional offset. With is between you set two right sides.
  • Error message — the text visitors see. Write what to do, not only what is wrong: “The return date must be after the departure date.”
  • Show the error on — the field that shows the message and is marked in red. By default it is the first field the rule uses, but you can pick any field, for example the second date so the message appears where the visitor just typed.
  • Also show the error when a compared field is empty — off by default; see Empty fields below.
  • Only check this rule when — an optional condition; see Conditions below.

Offsets

The right side can have an offset. For dates it is a number of days, for times minutes or hours, for a date + time days, hours or minutes, and for numbers an amount. Use a positive or negative number. Examples: “Check-out is on or after Check-in plus 2 days”, “End time is at or later than Start time plus 30 minutes”, “Departure is on or after Today plus 7 days”, “Deposit is less than or equal to Total plus -50”.

Fixed values

A fixed value is always typed in one format, whatever the date format of the form: dates as YYYY-MM-DD (for example 2027-03-31), times as HH:MM in 24 hour time (14:00), a date + time as YYYY-MM-DD HH:MM, and numbers with a decimal dot (99.5). Text values are compared as typed, with the case option of the rule.

Rule types and comparisons

Dates

Date rules work with every Gravity Forms date field: the date picker, the three separate fields and the drop-downs, in every format (month/day/year, day/month/year and year/month/day, with slashes, dashes or dots). The add-on reads each date with the format of its own field, so 05/03/2027 is 3 May in a month-first field and 5 March in a day-first field. Comparisons: is after, is on or after, is before, is on or before, is the same as, is not the same as, is between, is at least … apart from and is at most … apart from. The two “apart” comparisons measure the distance in days in either direction, for example a minimum stay of 2 nights or a rental of at most 14 days. Today uses the time zone of your site.

Times

Time rules work with the Gravity Forms time field in 12 hour (with AM/PM) and 24 hour format. 12 AM is midnight and 12 PM is noon. Comparisons: is later than, is at or later than, is earlier than, is at or earlier than, is the same as, is not the same as, is between and the two “apart” comparisons in minutes or hours. A time rule compares times of day; if the end can be on the next day, use a date + time rule.

Date + time

A date + time rule combines a date field and a time field on each side, so “the end is at least 2 hours after the start” also works across midnight and across days. It has all the date comparisons plus is on the same day as, and the offset and distance can be days, hours or minutes.

Numbers, prices and totals

Number rules work with number fields, quantity fields, the price and quantity of a single product, and the order total. Each value is read the way the field shows it: with a decimal dot or comma as set on the number field, and with the decimal and thousands separators of your Gravity Forms currency for money fields, so 1.250,50 and $1,250.50 are both read correctly. Comparisons: is less than or equal to, is less than, is greater than or equal to, is greater than, equals, does not equal and is between (both ends included).

Text

Text rules compare any field as text: single line and paragraph text, e-mail, phone, website, drop-downs and radio buttons, and the parts of a name or address. Comparisons: is the same as, is different from, contains and does not contain. Ignore upper / lower case is on by default, so Ann@Mail.com matches ann@mail.com. Spaces at the start and end are always ignored.

A group of fields

Group rules look at several fields at once. Tick the fields that belong to the group, then choose:

  • The sum of these fields equals, is at most or is at least a value — for percentages that must add up to 100, or seats that may not exceed the room size. Empty fields count as 0 once at least one field is filled in.
  • At least one of these fields is filled in — for example a phone number or a mobile number.
  • Exactly one of these fields is filled in — for example a voucher code or a gift card, not both.
  • All or none of these fields are filled in — for example a company name and a VAT number for business bookings.

Conditions

Tick Only check this rule when to limit a rule. Choose whether all or any of the lines must match, then add lines of the form field – operator – value. Operators: is, is not, greater than, less than, contains, starts with, ends with, is empty and is not empty. Text is compared without regard to upper and lower case. Example: the rule “Return date is after Departure date” only matters for return trips, so its condition is “Trip type is Return”. A field hidden by conditional logic has no value for a condition.

Empty and hidden fields

A comparison needs two values. When a compared field is empty, the rule is skipped by default: the return date rule does not complain while the return date is still empty, and you keep the Required setting of the field itself for “this must be filled in”. Tick Also show the error when a compared field is empty when an empty value should break the rule; the message of the rule is then shown when the visitor leaves the field empty.

Fields hidden by Gravity Forms conditional logic are never compared, even if a value was typed in before they were hidden. A rule whose error field is hidden is skipped too. The server applies the same logic, so a hidden field cannot block a submission.

What visitors see

A booking form with live errors: the return date is before the departure, the drop-off time is before the pick-up time and both a voucher and a gift card were entered
Live checks: the messages appear while the visitor fills in the form.

As soon as a visitor changes or leaves a field that a rule uses, the rule is checked and its message appears below the chosen field, in the normal Gravity Forms error style, and disappears as soon as the answers fit. While a visitor is still typing, the add-on only reports what cannot be fixed by filling in more fields: an “at least one” rule waits until the visitor tries to continue, and a sum waits until every field of the group has a value. When the visitor presses Next or Submit, every rule of the current page is checked; if one fails, the form does not go on and the first field with an error is scrolled into view.

A hotel form sent with scripts switched off: the server refuses it and shows each rule message on its own field, Check-out and Arrival time
The server check: a form sent without any script gets the same messages, and no entry is saved.

The browser check is for comfort only. Every rule is checked again on the server for every submission, so a visitor who switches off scripts, an old browser or a bot that posts the form directly gets the same messages and no entry is saved until the answers fit.

Multi-page forms

On a multi-page form each rule runs on the page that shows its error. When a visitor presses Next, the rules whose error field is on the current page are checked, so a rule on page 2 that compares with a field on page 1 waits until the visitor reaches page 2. On the final submit the server checks every rule again; if a rule fails on an earlier page, the visitor is taken back to that page with the message shown.

Examples

  • Travel: Return date is after Departure date, only when Trip type is Return; Departure date is on or after Today; Drop-off time is later than Pick-up time.
  • Hotels and rentals: Check-out is at least 2 days apart from Check-in; Arrival time is at or later than 14:00.
  • Quotes and budgets: Minimum budget is less than or equal to Maximum budget; Deposit is less than or equal to Order total; the sum of Marketing %, Sales % and Research % equals 100.
  • Sign-up: Confirm e-mail is the same as E-mail; Nickname is different from Username; at least one of Phone and Mobile is filled in.
  • Events: Event end (date + time) is at most 12 hours apart from Event start; Number of guests is between 1 and 9.

How the checks work

Rules are stored with the form. When a form with rules is shown, the add-on passes the rules and a few facts about the fields they use (date format, time format, decimal separator, page number) to a small script. That script and the server use the same steps: a date becomes a day number, a time becomes minutes after midnight, a date + time becomes minutes since a fixed start, a number is read with the right decimal separator, and text is trimmed and, if you chose so, lower-cased. Because both sides use the same steps, the browser and the server always agree, and the server has the last word. The server check runs in the Gravity Forms gform_validation filter, after the checks of each field, so the messages of Gravity Forms itself (for example a required field) come first on a field that has both.

Privacy and performance

Everything runs on your own server and in the visitor’s browser. The add-on makes no outside HTTP request beyond checking gravityextra.com for your licence and plugin updates, stores nothing about visitors, and only loads its script on forms that have at least one enabled rule. Uninstalling the add-on removes its options and the rules stored in your forms; forms and entries are kept.

Troubleshooting

  • A rule never fires — check that it is enabled, that its condition matches, that the compared fields are not hidden by conditional logic and are filled in (or tick the empty option), and that the licence is active.
  • A date is read the wrong way round — the add-on uses the date format set on each date field. Check the field’s Date Format setting in the form editor.
  • A rule disappeared after saving — it was incomplete (a field or value missing) or a field it used was deleted. Add it again with all parts filled in.
  • The message shows on another field — change Show the error on in the rule.

Still need help?

Our support team answers tickets every day, usually within a few hours.

0
0
Your Cart
Your cart is emptyReturn to Shop
🔥 FREQUENTLY BOUGHT TOGETHER
Complete Combo & Save 40%!
ITEM IN YOUR CART
Gravity Forms Klaviyo Add-on
$39.00/yr
+
🎁 RECOMMENDED ADD-ON SAVE 40% OFF
Original Price: $39.00/yr
Bundle Special Price: $23.40/yr