# Maximum allowed for 2 Number fields combined \[RESOLVED\]

**URL:** <https://community.gravityforms.com/t/maximum-allowed-for-2-number-fields-combined-resolved/3389>\
**Category:** Get Help\
**Tags:** gform\_validation\
**Created:** [December 4, 2019, 3:37pm UTC](https://community.gravityforms.com/t/maximum-allowed-for-2-number-fields-combined-resolved/3389 "2019-12-04T15:37:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![user5b9bef514540f0.6](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/user5b9bef514540f0.6/32/1205_2.png) [@user5b9bef514540f0.6](https://community.gravityforms.com/u/user5b9bef514540f0.6)\
**Post date:** [December 4, 2019, 3:37pm UTC](https://community.gravityforms.com/t/maximum-allowed-for-2-number-fields-combined-resolved/3389/1 "2019-12-04T15:37:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [December 5, 2019, 1:08am UTC](https://community.gravityforms.com/t/maximum-allowed-for-2-number-fields-combined-resolved/3389/2 "2019-12-05T01:08:52Z")

</div>

You could do that using the gform\_validation filter:

> **[gform\_validation - Gravity Forms Documentation](https://docs.gravityforms.com/gform_validation/)**
>
> The "gform\_validation" filter allows custom validation logic to be used by Gravity Forms when a form is submitted. This allows more granular validation of fields than the default validation used.

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

---

<div class="post-metadata">

**Author:** ![user5b9bef514540f0.6](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/user5b9bef514540f0.6/32/1205_2.png) [@user5b9bef514540f0.6](https://community.gravityforms.com/u/user5b9bef514540f0.6)\
**Post date:** [December 5, 2019, 2:04pm UTC](https://community.gravityforms.com/t/maximum-allowed-for-2-number-fields-combined-resolved/3389/3 "2019-12-05T14:04:22Z")

</div>

Chris, thank you!

I had tried the code example at [https://docs.gravityforms.com/gform\_field\_validation/#1-number-field-validation](https://docs.gravityforms.com/gform_field_validation/#1-number-field-validation) 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.

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [December 5, 2019, 5:49pm UTC](https://community.gravityforms.com/t/maximum-allowed-for-2-number-fields-combined-resolved/3389/4 "2019-12-05T17:49:07Z")

</div>

Closed on December 5, 2019, 5:49pm UTC


