# Get city population after user's city is entered? \[RESOLVED\]

**URL:** https://community.gravityforms.com/t/get-city-population-after-users-city-is-entered-resolved/5645
**Category:** Get Help
**Tags:** custom, gform\_pre\_submission, gform\_field\_validation, zip-code
**Created:** [August 7, 2020, 2:22pm UTC](https://community.gravityforms.com/t/get-city-population-after-users-city-is-entered-resolved/5645 "2020-08-07T14:22:24Z")
**Posts on this page:** 1
**Showing post:** 4

<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: [August 7, 2020, 6:21pm UTC](https://community.gravityforms.com/t/get-city-population-after-users-city-is-entered-resolved/5645/4 "2020-08-07T18:21:38Z")

</div>

OK. I think in that case I recommend using gform\_field\_validation. You can read that file (either CSV or JSON) using PHP and this filter:

> **[gform\_field\_validation](https://docs.gravityforms.com/gform_field_validation/)**
>
> Discover how to validate fields in Gravity Forms. Guarantee data integrity and accuracy during form submission.

Then you can return a validation error (message if they are on the No list) or let them pass to the next page if they are on the Yes list. There is a possibility they are not on either list, and I am not sure what you want to return to them in that case.

We covered doing something like that here:

> [@Validate ZIP Code against a list of codes](https://community.gravityforms.com/t/validate-zip-code-against-a-list-of-codes/1635/9):
>
> Update: Super close to accomplishing, but I am facing an issue. When users enter the correct zip it works as it should, but if they enter the wrong zip code, it just gives me a never ending orange circle (I guess trying to validate it). Thing is, it works on the gravity forms “preview” sections, but not on the live site. This is the code: add\_filter( 'gform\_field\_validation\_2\_48', 'custom\_validation', 10, 4 ); function custom\_validation( $result, $value, $form, $field ) { $url = 'https://dom…

and

> [@Zip Code Field Validation](https://community.gravityforms.com/t/zip-code-field-validation/869/8):
>
> Then you’d add a seperate add\_filter for that form + field ID (and I’d select it at field type address inside the function instead of the field ID to keep it compact & more scalable).

Take a look at those topics and let us know if you need a nudge in the right direction.

---

_[View the full topic](https://community.gravityforms.com/t/get-city-population-after-users-city-is-entered-resolved/5645)._
