title: Gravity Forms regex for US ZIP code
body: <p>I'm trying to set up some form validation for a Gravity Form that I've created. One of the fields that I need to validate is a US ZIP code. I want to pass ZIPs that follow the <code>nnnnn</code> and <code>nnnnn-nnnn</code> patterns. Here's my code:</p>
  
  <pre><code>    if ( $field-&gt;type == 'address' ) {
  
      $zip = rgar( $value, $field-&gt;id . '.5' );
  
      if ( preg_match( "(^(?!0{5})(\d{5})(?!-?0{4})(|-\d{4})?$)", $zip ) &amp;&amp; ! $field-&gt;get_input_property( '5', 'isHidden' )
      ) {
          $result['is_valid'] = false;
          $result['message']  = empty( $field-&gt;errorMessage ) ? __( 'Please enter a valid ZIP code (ie. 00000 or 00000-0000).', 'gravityforms' ) : $field-&gt;errorMessage;
      } else {
          $result['is_valid'] = true;
          $result['message']  = '';
      }
  }
  </code></pre>
  
  <p>My form continues to fail validation and I can't figure out why. I've double checked that <code>.5</code> is the correct input field number of the ZIP code. Any suggestions?</p>
  
  <p>My form can be found at <a href="http://marcusjones.wpengine.com/" rel="nofollow">http://marcusjones.wpengine.com/</a></p>