🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!
Guides & Tutorials October 31, 2026

How to Validate Gravity Forms Fields Against Each Other (Dates, Times, Totals and More)

GravityExtra
How to Validate Gravity Forms Fields Against Each Other (Dates, Times, Totals and More)

Every form builder can tell you that a date is a valid date. Far fewer can tell you that the return date is before the departure date. That second kind of mistake is the one that costs time: the entry arrives, it looks complete, and only when someone reads it closely do they notice that the car is booked to be returned two hours before it is picked up, that the shares of a budget add up to 94 percent, or that the deposit is larger than the total. Each answer was valid on its own. Together, they are impossible.

This guide explains what cross-field validation is, why Gravity Forms does not do it out of the box, which checks are worth adding to which forms, and how to set them up without writing code, using the Gravity Forms Cross-Field Validation Rules add-on. The checklist and the examples are useful however you decide to build your forms.

What is cross-field validation?

Validation is the step that decides whether a submitted form is accepted. Most validation looks at one field at a time: is this field filled in, is this an e-mail address, is this number between 1 and 10. Cross-field validation looks at the relationship between fields. It answers questions such as:

  • Is the end date after the start date?
  • Is the end time later than the start time, and by at least thirty minutes?
  • Is the maximum at least as high as the minimum?
  • Do these three percentages add up to exactly 100?
  • Is the deposit no more than the order total?
  • Did the visitor give at least one way to reach them: a phone, a mobile number or an e-mail?
  • Did they enter a voucher code or a gift card number, but not both?
  • Is the confirmation e-mail the same as the e-mail address?

None of these can be answered by looking at one field. They need two or more answers at the same time, and often the current date or time as well.

What Gravity Forms checks today, and where the gap is

Gravity Forms has solid validation for single fields. You can make a field required, set a number range, refuse duplicate values, check that a date or an e-mail address is well formed, and on some fields ask the visitor to type a value twice. What it does not have is a setting that says “this field must be greater than that field” or “these fields must add up to 100”. The usual workaround is a snippet of PHP in the theme that hooks into the validation step for one specific form and one specific pair of fields. It works until someone changes a field, duplicates the form or moves to a new theme, and it gives no feedback until the visitor presses Submit.

How the different kinds of validation compare

  • Gravity Forms core checks each field against its own settings: required, number range, no duplicates, the format of dates and e-mail addresses. It does not compare one field with another.
  • Live, per-field validation, such as our own Live Field Validation add-on, runs those single-field checks while the visitor types, so mistakes show up before the form is sent. It still checks each field on its own and does not compare fields with each other; it pairs well with cross-field rules.
  • Pattern (regular expression) checks, which several free plugins offer, test that one field matches a pattern, such as a postcode, an order number or a licence plate. They look at one value and cannot express “after”, “at least 3 days apart” or “adds up to 100”.
  • Cross-field rules compare fields with each other, with fixed values and with today or now, and check groups of fields. They fill exactly the gap the other three leave.

The checks worth adding, form by form

Most forms only need two or three rules. These are the ones that prevent the most follow-up e-mails.

Bookings, rentals and travel

  • Return or check-out date after the departure or check-in date.
  • Check-out at least the minimum number of nights after check-in, or at most the maximum rental period.
  • Departure date on or after today, or at least a few days from today if you need preparation time.
  • Drop-off time later than pick-up time, or a date + time pair when the rental can run over several days.
  • Arrival time at or after the earliest check-in time.

Quotes, orders and budgets

  • Minimum budget less than or equal to maximum budget.
  • Deposit less than or equal to the order total.
  • Quantity of one product no more than the number of seats or rooms.
  • Percentages or shares that add up to exactly 100.

Sign-up and contact forms

  • Confirm e-mail the same as e-mail, without caring about upper and lower case.
  • Nickname or display name different from the username.
  • At least one of phone, mobile and e-mail filled in.
  • Company name and VAT number: all or none.

Events, shifts and schedules

  • End time later than start time, or at least 30 minutes later.
  • A shift at most 12 hours long, measured with a date and a time on each side so it works across midnight.
  • Number of guests between 1 and the maximum per booking.

Setting up a rule step by step

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
A rule in the editor: what to compare, the comparison, the message, the error field and a condition.

With the add-on installed, open a form and go to Settings → Validation Rules. Each rule is a short sentence you build from drop-downs:

  • Choose what to compare: dates, times, a date + time from two fields, numbers (including prices and the order total), text, or a group of fields.
  • Pick the left side, usually a field. Date rules can also start from today, time rules from now.
  • Pick the comparison, for example is after, is at least … apart from or is less than or equal to.
  • Pick the right side: another field, a fixed value, today or now, plus an offset such as 3 days or 30 minutes if you need one.
  • Write the message and choose the field that shows it. A good message says what to do: “The return date must be after the departure date.”
  • If the rule only applies sometimes, add a condition, for example only when Trip type is Return.

Save the rules and try the form. That is all: no code, no theme files, and the rules travel with the form when you duplicate or export it.

Dates, times and numbers are trickier than they look

A hand-written snippet often breaks on the details. These are the ones a good rule engine has to get right.

Date formats

The same text means different dates in different formats: 05/03/2027 is the third of May in a month-first field and the fifth of March in a day-first field. Gravity Forms supports month/day/year, day/month/year and year/month/day with slashes, dashes or dots, as a date picker, three separate fields or drop-downs. The add-on reads every date with the format of its own field before comparing, so a rule between a day-first and a month-first field still compares the right days, and leap years are handled.

12 and 24 hour times

In 12 hour time, 12 AM is midnight and 12 PM is noon, which trips up many quick comparisons. Times are turned into minutes after midnight before they are compared. When the end can fall on the next day, compare a date and a time on each side instead of the time alone.

Decimal commas and currencies

1.250,50 is one thousand two hundred and fifty in much of Europe and a strange number elsewhere. Number fields can use a decimal dot or comma, and money fields use the separators of your Gravity Forms currency. The add-on reads each value the way its field shows it, so a deposit rule works the same for a shop in euros and one in dollars.

Empty and hidden fields

If the return date is still empty, is the rule broken? Usually not: the visitor simply has not got there yet, and whether the field must be filled in is the job of the field’s own Required setting. Rules therefore skip empty fields unless you tick the option that makes an empty value an error. Fields hidden by conditional logic are never compared, even if something was typed before they were hidden, so a hidden question can never block a submission.

Live feedback and a server that has the last word

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: each message appears on the chosen field while the visitor fills in the form.

Good validation has two layers. The first runs in the browser: as soon as a visitor changes or leaves a field that a rule uses, the rule is checked and the message appears under the right field, in the normal Gravity Forms error style. It disappears as soon as the answers fit. Pressing Next or Submit checks every rule of the current page and stops if one fails, so visitors fix the problem while the answers are still in front of them.

The second layer runs on the server, for every submission, in the same validation step Gravity Forms uses for its own checks. It does not trust the browser. A visitor who switches off scripts, an outdated browser or a bot that posts the form directly gets exactly the same messages, and no entry is saved until the answers fit. Because the browser and the server use the same steps to read dates, times and numbers, they always reach the same answer.

Multi-page forms

On a form with several pages, a rule should complain on the page where the visitor can fix it. Each rule therefore runs on the page that shows its error. If the end date on page two must be after the start date on page one, the rule waits until page two and shows its message there. On the final submit every rule is checked again on the server, and if a rule on an earlier page fails, the visitor is taken back to that page with the message shown.

A short checklist before you publish

  • Write messages that say what to do, and show them on the field the visitor will change.
  • Test each rule twice: once with answers that should pass, once with answers that should fail.
  • Test the edges: the same day, noon and midnight, exactly 100, the lowest and highest allowed number.
  • Use conditions for rules that only apply to some visitors, instead of making the rule more complex.
  • Keep the Required setting on the fields themselves; use the empty option of a rule only when an empty value really breaks the relationship.
  • Submit one form with scripts switched off to see the server check at work.

Privacy and performance

Rules run 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 small script on forms that have at least one rule. The full list of rule types, operators and settings is in the Cross-Field Validation Rules documentation.

Wrapping up

Single-field validation catches typing mistakes. Cross-field validation catches answers that cannot all be true at once: an end before a start, a maximum below a minimum, shares that do not add up. Adding two or three rules to each important form takes minutes, saves the e-mails that ask visitors what they really meant, and gives you entries you can act on straight away. Ready to stop impossible answers at the form? Get Gravity Forms Cross-Field Validation Rules.

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