Maximum allowed for 2 Number fields combined [RESOLVED]

I’m working on a Booking Request form for a timeshare. I need to limit the total number of occupants to 6. I have fields for “Number of Adults” and “Number of Children”.

How might I limit these fields so that the grand total cannot exceed 6? For example, if the user enters 4 for number of adults, that the Maximum for number of children is set to 2?

You could do that using the gform_validation filter:

You would check to see if the combined total of those two selections is more than 6, and return a validation error if so.

Chris, thank you!

I had tried the code example at but it wasn’t working. Then I realized the reason was that the calculation was in a Hidden field. Once I made that Visible, the validation worked as expected.

Thanks again for your time.

1 Like