# Validate field against database

**URL:** <https://community.gravityforms.com/t/validate-field-against-database/5998>\
**Category:** Get Help\
**Tags:** gform\_field\_validation, serial-number\
**Created:** [September 3, 2020, 6:00pm UTC](https://community.gravityforms.com/t/validate-field-against-database/5998 "2020-09-03T18:00:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrWebsiteDesigner](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/mrwebsitedesigner/32/1979_2.png) [@MrWebsiteDesigner](https://community.gravityforms.com/u/MrWebsiteDesigner)\
**Post date:** [September 3, 2020, 6:00pm UTC](https://community.gravityforms.com/t/validate-field-against-database/5998/1 "2020-09-03T18:00:37Z")

</div>

What would be the best way to validate a field entry against a database? For example, a customer registers a new product with a serial #. That serial # (and the rest of customer info) gets stored in a database. The customer comes back some time later to do a warranty request. There’s one form field visible asking them for their serial #. The customer types in their serial # and clicks continue. The form then checks the database to see if that serial # exists. If it does, it shows the rest of the form fields to fill out. If it doesn’t, an error message informs them that serial# doesn’t exist.  
Would this function be done through Gravity Forms and Zapier or Webhooks or something else?

I did find this: [https://pastebin.com/7ANQh6Rc](https://pastebin.com/7ANQh6Rc)  
How would that need to be modified to access a WordPress database as opposed to a .txt file?

---

<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:** [September 3, 2020, 7:52pm UTC](https://community.gravityforms.com/t/validate-field-against-database/5998/2 "2020-09-03T19:52:12Z")

</div>

To modify that code to refer to a database rather than a text file would require you write the code to connect to the database to perform the validation.

This plugin can handle that scenario out of the box:

> **[Gravity Forms Populate Anything - Gravity Wiz](https://gravitywiz.com/documentation/gravity-forms-populate-anything/)**
>
> Dynamically filter and populate field choices and values with posts, users, taxonomies, terms, Gravity Forms entries, and databases. Pretty much anything!

If you are open to using that plugin, I recommend contacting Gravity Wiz to ask them how this can be accomplished. Thank you.

---

<div class="post-metadata">

**Author:** ![richardw8k](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/richardw8k/32/2354_2.png) [@richardw8k](https://community.gravityforms.com/u/richardw8k)\
**Post date:** [January 4, 2022, 5:55pm UTC](https://community.gravityforms.com/t/validate-field-against-database/5998/3 "2022-01-04T17:55:24Z")

</div>


