<?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: Limit date range</title>
		<link>https://legacy.forums.gravityhelp.com/topic/limit-date-range</link>
		<description>Gravity Support Forums Topic: Limit date range</description>
		<language>en-US</language>
		<pubDate>Mon, 20 Apr 2026 15:20:22 +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/limit-date-range" rel="self" type="application/rss+xml" />

		<item>
			<title>Chris Hajer on "Limit date range"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/limit-date-range#post-68034</link>
			<pubDate>Thu, 26 Jul 2012 07:02:32 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">68034@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;redjelly, please begin a new topic for your issue and explain clearly what you would like to do.  We'll be happy to help.  Reference this topic if it's relevant.  Thank you.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>redjelly on "Limit date range"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/limit-date-range#post-68017</link>
			<pubDate>Thu, 26 Jul 2012 02:52:46 +0000</pubDate>
			<dc:creator>redjelly</dc:creator>
			<guid isPermaLink="false">68017@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;+1.&#60;br /&#62;
I'm trying to do a similar thing (I have date fields that I want to check against the current date to check if the user is of legal age). I scoured the forums and the docs, but cannot find the proper way to reference multiple subfields. Before I get sent to the validation hooks tutorial, all that is stated there is that &#34;we will discuss multiple inputs at a future time&#34;. &#60;/p&#62;
&#60;p&#62;Can you *please* let us know how to do this? I've tried variations on the is_age function above with no success.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Tmpg Developer on "Limit date range"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/limit-date-range#post-61217</link>
			<pubDate>Sun, 03 Jun 2012 08:03:57 +0000</pubDate>
			<dc:creator>Tmpg Developer</dc:creator>
			<guid isPermaLink="false">61217@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I think in line 54 &#38;amp; 56, 'age' is missing the leading '$' for a php variable- should be $age in the is_age() function- could be part of the issue?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Tmpg Developer on "Limit date range"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/limit-date-range#post-59724</link>
			<pubDate>Mon, 21 May 2012 16:49:08 +0000</pubDate>
			<dc:creator>Tmpg Developer</dc:creator>
			<guid isPermaLink="false">59724@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Has There been a solution to this thread?  We are trying the same thing over here.&#60;/p&#62;
&#60;p&#62;Thank you in advance.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Limit date range"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/limit-date-range#post-40448</link>
			<pubDate>Tue, 08 Nov 2011 11:47:41 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">40448@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Please post your functions.php at pastie.org or pastebin.com. The error is on line 375 in that functions.php file.  I'd like to see if you have the name of a function wrong or something.  Take a look at that file, or post the content so we can see it ourselves.  Thank you.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>OllieJ317 on "Limit date range"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/limit-date-range#post-40414</link>
			<pubDate>Tue, 08 Nov 2011 09:45:43 +0000</pubDate>
			<dc:creator>OllieJ317</dc:creator>
			<guid isPermaLink="false">40414@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hey! Thank you for the quick response. When I click the submit button, I get a &#60;/p&#62;
&#60;p&#62;Fatal error: Class 'Date' not found in /home/content/i/n/d/indiangig/html/wp-content/themes/motormediausa/functions.php on line 375&#60;/p&#62;
&#60;p&#62;As I said, I've been trying to make the connection between the VIN# validation script and what I'm attempting to do here and just getting nowhere with it.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Limit date range"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/limit-date-range#post-40390</link>
			<pubDate>Tue, 08 Nov 2011 03:48:14 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">40390@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;What happens when you run that code?  And can we see this in action somewhere?  Thank you.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>OllieJ317 on "Limit date range"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/limit-date-range#post-40347</link>
			<pubDate>Tue, 08 Nov 2011 00:54:40 +0000</pubDate>
			<dc:creator>OllieJ317</dc:creator>
			<guid isPermaLink="false">40347@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hey I've been reading through the gform_validation_hook tutorial repeatedly and I just can't seem to make the connection from the example given to the goal that I have in mind. &#60;/p&#62;
&#60;p&#62;I basically want to create a birth date validator that would suspend the registration process if the supplied birthday doesn't add up to the age of 21 (on December 8, 2011). &#60;/p&#62;
&#60;p&#62;Here's the link to my form: &#60;a href=&#34;http://motormediausa.com/test/&#34; rel=&#34;nofollow&#34;&#62;http://motormediausa.com/test/&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;And here's my code: &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;// CUSTOM AGE VERIFICATION
add_filter( &#38;#39;gform_validation_1&#38;#39;, &#38;#39;age_validation&#38;#39;);
function age_validation($validation_result){

	$form = $validation_result[&#38;#39;form&#38;#39;];
	foreach($form[&#38;#39;fields&#38;#39;] as &#38;amp;$field){
		// 5 - If the field does not have our designated CSS class, skip it
        if(strpos($field[&#38;#39;cssClass&#38;#39;], &#38;#39;validate-age&#38;#39;) === false)
            continue;

			// 7 - Check if the field is hidden by GF conditional logic
			$is_hidden = RGFormsModel::is_field_hidden($form, $field, array());

			// 8 - If the field is not on the current page OR if the field is hidden, skip it
			if($field_page != $current_page &#124;&#124; $is_hidden)
			continue;

			// 9 - Get the submitted value from the $_POST
			$field_value = rgpost(&#38;quot;input_{$field[&#38;#39;id&#38;#39;]}&#38;quot;);

			// 10 - Make a call to your validation function to validate the value
			$is_valid = is_age($field_value);

			// 11 - If the field is valid we don&#38;#39;t need to do anything, skip it
			if($is_valid)
				continue;

			// 12 - The field field validation, so first we&#38;#39;ll need to fail the validation for the entire form
			$validation_result[&#38;#39;is_valid&#38;#39;] = false;

			// 13 - Next we&#38;#39;ll mark the specific field that failed and add a custom validation message
			$field[&#38;#39;failed_validation&#38;#39;] = true;
			$field[&#38;#39;validation_message&#38;#39;] = &#38;#39;The birthday you have entered indicates that you are not of legal drinking age and will be ineligible to compete in this tournament.&#38;#39;;

    }

	// 14 - Assign our modified $form object back to the validation result
    $validation_result[&#38;#39;form&#38;#39;] = $form;

    // 15 - Return the validation result
    return $validation_result;
}

function is_age($age) {
		$day = (&#38;quot;#input_1_3_2&#38;quot;);
		$month = (&#38;quot;#input_1_3_1&#38;quot;);
		$year = (&#38;quot;#input_1_3_3&#38;quot;);
		$age = 21;

	$mydate=new Date();
	mydate.setFullYear(1990,11-1,8);

	$currdate = new Date();
	currdate.setFullYear(currdate.getFullYear() - age);
	if ((currdate - mydate) &#38;lt; 0){
	alert(&#38;quot;Sorry, only persons over the age of &#38;quot; + age + &#38;quot; may enter this competition.&#38;quot;);
	return false;
	}
	return true;
	};&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Any help that you could provide would be excellent. Thank you.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Limit date range"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/limit-date-range#post-38795</link>
			<pubDate>Mon, 24 Oct 2011 14:16:38 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">38795@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Please let us know if you need help implementing something.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>g0shu4 on "Limit date range"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/limit-date-range#post-38762</link>
			<pubDate>Mon, 24 Oct 2011 12:34:53 +0000</pubDate>
			<dc:creator>g0shu4</dc:creator>
			<guid isPermaLink="false">38762@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;That link is an excellent walk-through that I had not yet read.&#60;/p&#62;
&#60;p&#62;Thanks.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
