PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

ZipCode Validation Questions

  1. #1: Have a 5 digit zip code on a form and need to verify length = 5 and all values are numeric. To implement with javascript where would I put the js? To implement with php, where would I put the code?

    #2: With same 5 digit zip code form. I want to verify the zip entered against a table. How do I go about creating a mysql zipcode table from a spreadsheet or csv? Where would I add php code to perform an exact match lookup? And how do I handle bubbling up an error message back to the user?

    Posted 14 years ago on Tuesday May 3, 2011 | Permalink
  2. I can't help you with the JS, only to tell you the JS would go in the theme template file used to display the page that contains the form. As for doing it with PHP, you would place the custom PHP in your themes functions.php file.

    To do it with PHP you would use the gform_validation hook. Documentation for this hook can be found here:

    http://www.gravityhelp.com/documentation/page/Gform_validation

    A complete tutorial on how to use the gform_validation hook can be found here:

    http://www.gravityhelp.com/documentation/page/Using_the_Gravity_Forms_%22gform_valiation%22_Hook

    As for creating a MySQL table for your custom zipcode data, you'd have to look that up on how to use MySQL. That is outside the scope of Gravity Forms itself and more general MySQL/PHP type information. Your code to match against this data would be part of the code you write for the gform_validation hook that would go in your themes functions.php file.

    Posted 14 years ago on Tuesday May 3, 2011 | Permalink