<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Require just the zip code?</title>
		<link>https://legacy.forums.gravityhelp.com/topic/require-just-the-zip-code</link>
		<description>Gravity Support Forums Topic: Require just the zip code?</description>
		<language>en-US</language>
		<pubDate>Wed, 22 Apr 2026 10:51:30 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/require-just-the-zip-code" rel="self" type="application/rss+xml" />

		<item>
			<title>shmooth on "Require just the zip code?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/require-just-the-zip-code#post-14770</link>
			<pubDate>Mon, 20 Dec 2010 04:41:44 +0000</pubDate>
			<dc:creator>shmooth</dc:creator>
			<guid isPermaLink="false">14770@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi all,&#60;/p&#62;
&#60;p&#62;Thought I'd add a note for other n00bs like me:&#60;/p&#62;
&#60;p&#62;1) when I first copied this example, I somehow got rid of the following line -- that will break things:&#60;/p&#62;
&#60;p&#62;    $form = $validation_result[&#34;form&#34;];&#60;/p&#62;
&#60;p&#62;2) to get access to the submitted data, you have to access it via the regular HTTP $_POST[&#34;input_name&#34;] PHP server variable (where 'input_name' is probably 'input_1', etc.), b/c at this stage of processing, the $form does not seem to have the submitted values set.&#60;/p&#62;
&#60;p&#62;so, my full, working test example is:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;#39;gform_validation&#38;#39;, &#38;#39;custom_validation&#38;#39;);

function custom_validation($validation_result){

    $form = $validation_result[&#38;quot;form&#38;quot;];

    // if value of first field name != &#38;#39;peter&#38;#39;
    if( strcmp($_POST[&#38;quot;input_1&#38;quot;],&#38;quot;peter&#38;quot;)!=0 ){  

        // then mark this submission invalid
        $validation_result[&#38;quot;is_valid&#38;quot;] = false;

        // mark the errant field [the first (0th) field]
        $form[&#38;quot;fields&#38;quot;][0][&#38;quot;failed_validation&#38;quot;] = true;

        // and put in an explanatory message to the user on how to fix
        $form[&#38;quot;fields&#38;quot;][0][&#38;quot;validation_message&#38;quot;] = &#38;quot;This first field must have the value &#38;#39;peter&#38;#39;.&#38;quot;;
    }

    // update the form in the validation result with the form object you modified
    $validation_result[&#38;quot;form&#38;quot;] = $form;

    return $validation_result;
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>Carl Hancock on "Require just the zip code?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/require-just-the-zip-code#post-12782</link>
			<pubDate>Tue, 16 Nov 2010 19:32:59 +0000</pubDate>
			<dc:creator>Carl Hancock</dc:creator>
			<guid isPermaLink="false">12782@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;A complete list of filters will be available with the new documentation that will launch along with the 1.5 final release once it is out of beta testing.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ananda on "Require just the zip code?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/require-just-the-zip-code#post-12781</link>
			<pubDate>Tue, 16 Nov 2010 19:11:38 +0000</pubDate>
			<dc:creator>ananda</dc:creator>
			<guid isPermaLink="false">12781@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Superb. Thanks, Alex.&#60;/p&#62;
&#60;p&#62;Is there a complete list of filters anywhere?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Alex Cancado on "Require just the zip code?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/require-just-the-zip-code#post-12662</link>
			<pubDate>Sat, 13 Nov 2010 20:54:56 +0000</pubDate>
			<dc:creator>Alex Cancado</dc:creator>
			<guid isPermaLink="false">12662@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;You would actually need to use the gform_validation filter. Following is a simple example on how to fail a validation for the first field in the form. It should point you in the right direction&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php
add_filter(&#38;#39;gform_validation&#38;#39;, &#38;#39;custom_validation&#38;#39;);
function custom_validation($validation_result){

    // set the form validation to false
    $validation_result[&#38;quot;is_valid&#38;quot;] = false;
    $form = $validation_result[&#38;quot;form&#38;quot;];

    // specify the first field to be invalid and provide custom validation message
    $form[&#38;quot;fields&#38;quot;][0][&#38;quot;failed_validation&#38;quot;] = true;
    $form[&#38;quot;fields&#38;quot;][0][&#38;quot;validation_message&#38;quot;] = &#38;quot;This field is invalid!&#38;quot;;

    // update the form in the validation result with the form object you modified
    $validation_result[&#38;quot;form&#38;quot;] = $form;

    return $validation_result;

}
?&#38;gt;&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>ananda on "Require just the zip code?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/require-just-the-zip-code#post-12602</link>
			<pubDate>Fri, 12 Nov 2010 15:47:10 +0000</pubDate>
			<dc:creator>ananda</dc:creator>
			<guid isPermaLink="false">12602@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Alex, thanks for your answer. That's great to know. I see now that the hooks are documented.&#60;/p&#62;
&#60;p&#62;Looks like I would use gform_pre_submission to run a validation on the zip code and -- somehow?? -- stop the form?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Alex Cancado on "Require just the zip code?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/require-just-the-zip-code#post-12576</link>
			<pubDate>Fri, 12 Nov 2010 10:31:35 +0000</pubDate>
			<dc:creator>Alex Cancado</dc:creator>
			<guid isPermaLink="false">12576@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Ananda,&#60;br /&#62;
This is possible through a hook and a few lines of PHP, but it will require some PHP experience.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ananda on "Require just the zip code?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/require-just-the-zip-code#post-12556</link>
			<pubDate>Thu, 11 Nov 2010 21:45:42 +0000</pubDate>
			<dc:creator>ananda</dc:creator>
			<guid isPermaLink="false">12556@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;We'd like to able to require just the zip code field of an address. Is this possible, using the pre-built address field?&#60;/p&#62;
&#60;p&#62;This is a form it would be good to do on:&#60;br /&#62;
&#60;a href=&#34;http://www.anandala.org/free-book-chapters/&#34; rel=&#34;nofollow&#34;&#62;http://www.anandala.org/free-book-chapters/&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Thanks!
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
