<?xml version="1.0"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>MachForm Community Forums Topic: Form Validation Rules - More than just forced value or email???</title>
<link>https://www.machform.com/forums/</link>
<description>MachForm Community Forums Topic: Form Validation Rules - More than just forced value or email???</description>
<language>en</language>
<pubDate>Wed, 06 May 2026 04:32:41 +0000</pubDate>

<item>
<title>mmason on "Form Validation Rules - More than just forced value or email???"</title>
<link>https://www.machform.com/forums/topic/form-validation-rules-more-than-just-forced-value-or-email#post-618</link>
<pubDate>Wed, 23 Jan 2008 11:24:57 +0000</pubDate>
<dc:creator>mmason</dc:creator>
<guid isPermaLink="false">618@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Yuniar - Thanks very much. - Mike
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "Form Validation Rules - More than just forced value or email???"</title>
<link>https://www.machform.com/forums/topic/form-validation-rules-more-than-just-forced-value-or-email#post-615</link>
<pubDate>Wed, 23 Jan 2008 11:05:51 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">615@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Mike, you will need to use text editor which has line numbers.&#60;/p&#62;
&#60;p&#62;One free alternative is to use this: &#60;a href=&#34;http://notepad-plus.sourceforge.net/uk/site.htm&#34; rel=&#34;nofollow&#34;&#62;http://notepad-plus.sourceforge.net/uk/site.htm&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;&#34;Notepad++ is a free source code editor and Notepad replacement, which supports several programming languages, running under the MS Windows environment.&#34;
&#60;/p&#62;</description>
</item>
<item>
<title>mmason on "Form Validation Rules - More than just forced value or email???"</title>
<link>https://www.machform.com/forums/topic/form-validation-rules-more-than-just-forced-value-or-email#post-613</link>
<pubDate>Wed, 23 Jan 2008 10:55:11 +0000</pubDate>
<dc:creator>mmason</dc:creator>
<guid isPermaLink="false">613@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I would like to add a post validation hook and I see how this is done from reading these posts. However since I am not blessed with line numbers in the php scripts. Could some one please give me another &#34;landmark&#34; to search for besides a line number as posted by Yuniar about 3 months ago:&#60;/p&#62;
&#60;p&#62;&#34;Modify includes/post-functions.php, insert the code below into line 772, above the query line........&#34;&#60;/p&#62;
&#60;p&#62;Tanks very much,&#60;br /&#62;
Mike
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "Form Validation Rules - More than just forced value or email???"</title>
<link>https://www.machform.com/forums/topic/form-validation-rules-more-than-just-forced-value-or-email#post-172</link>
<pubDate>Fri, 26 Oct 2007 05:45:50 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">172@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;That's just great. Glad to help.
&#60;/p&#62;</description>
</item>
<item>
<title>mpivon on "Form Validation Rules - More than just forced value or email???"</title>
<link>https://www.machform.com/forums/topic/form-validation-rules-more-than-just-forced-value-or-email#post-167</link>
<pubDate>Thu, 25 Oct 2007 23:52:27 +0000</pubDate>
<dc:creator>mpivon</dc:creator>
<guid isPermaLink="false">167@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;That's AWESOME.&#60;/p&#62;
&#60;p&#62;I'm sure that a lot of other folks will (eventually) benefit from this!&#60;/p&#62;
&#60;p&#62;Thanks.
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "Form Validation Rules - More than just forced value or email???"</title>
<link>https://www.machform.com/forums/topic/form-validation-rules-more-than-just-forced-value-or-email#post-163</link>
<pubDate>Thu, 25 Oct 2007 08:15:17 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">163@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Okay, I think you won't need to create another code inside &#60;strong&#62;post-functions.php&#60;/strong&#62;. You can remove that code.&#60;/p&#62;
&#60;p&#62;Now, what you need to do is to merge the code in &#60;strong&#62;hooks/custom_hooks.php&#60;/strong&#62;&#60;br /&#62;
You've created two function, simple merge the code from form2_hook_tix_validation() to form2_hook_post_validation(). So the whole function would be something like this:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;function form2_hook_post_validation($user_input){

	$inv = $user_input[&#38;#39;element_1&#38;#39;];

	// Insert office codes here - these are for ONTARIO ONLY
	if (strcasecmp($inv,&#38;quot;2788&#38;quot;) != 0
		&#38;#38;&#38;#38; strcasecmp($inv,&#38;quot;2816&#38;quot;) != 0
		&#38;#38;&#38;#38; strcasecmp($inv,&#38;quot;2906&#38;quot;) != 0
		&#38;#38;&#38;#38; strcasecmp($inv,&#38;quot;3104&#38;quot;) != 0
		&#38;#38;&#38;#38; strcasecmp($inv,&#38;quot;9999&#38;quot;) != 0)
	{
		$inv_status = &#38;#39;Registration is only open to persons with a valid Promotional code&#38;#39;;
	}
	else{
		$inv_status = true;
	}

	if($inv_status !== true){
		return $inv_status;
	}

	$tix = $user_input[&#38;#39;element_7&#38;#39;];
	if (
		strcasecmp($tix,&#38;quot;1&#38;quot;) != 0
		&#38;#38;&#38;#38; strcasecmp($tix,&#38;quot;2&#38;quot;) != 0
		&#38;#38;&#38;#38; strcasecmp($tix,&#38;quot;3&#38;quot;) != 0
		&#38;#38;&#38;#38; strcasecmp($tix,&#38;quot;4&#38;quot;) != 0
		&#38;#38;&#38;#38; strcasecmp($tix,&#38;quot;5&#38;quot;) != 0
	){
		$tix_status = &#38;#39;Max five tickets&#38;#39;;
	}else{
		$tix_status = true;
	}

	return $tix_status;

}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;&#60;code&#62;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;If you have more fields, do the same as above, just add the code into that function.&#60;br /&#62;
Let me know if you have any difficulty.
&#60;/p&#62;</description>
</item>
<item>
<title>mpivon on "Form Validation Rules - More than just forced value or email???"</title>
<link>https://www.machform.com/forums/topic/form-validation-rules-more-than-just-forced-value-or-email#post-162</link>
<pubDate>Thu, 25 Oct 2007 07:44:55 +0000</pubDate>
<dc:creator>mpivon</dc:creator>
<guid isPermaLink="false">162@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Okay.  Cool.  This worked... sort of.  However, I have more than one field on the form that requires error checking.  So, following your example, I did the following:&#60;/p&#62;
&#60;p&#62;Into &#34;Post-Functions.php&#34; I inserted the following code:&#60;/p&#62;
&#60;p&#62;//post_validation hook&#60;/p&#62;
&#60;p&#62;&#60;code&#62;if(function_exists(&#38;quot;form{$form_id}_hook_post_validation&#38;quot;)){&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;$result = call_user_func(&#38;quot;form{$form_id}_hook_post_validation&#38;quot;,$user_input);&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;if($result !== true){&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;$process_result[&#38;#39;custom_error&#38;#39;] = $result;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;}&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;}&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;&#60;code&#62;//ticket validation hook&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;if(function_exists(&#38;quot;form{$form_id}_hook_tix_validation&#38;quot;)){&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;$result = call_user_func(&#38;quot;form{$form_id}_hook_tix_validation&#38;quot;,$user_input);&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;if($result !== true){&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;$process_result[&#38;#39;custom_error&#38;#39;] = $result;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;}&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;}&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;THEN... I added the following code to the Hooks file:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;function form2_hook_post_validation($user_input){&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;$inv = $user_input[&#38;#39;element_1&#38;#39;];&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;// Insert office codes here - these are for ONTARIO ONLY&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;if (&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;strcasecmp($inv,&#38;quot;2788&#38;quot;) != 0&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#38;#38;&#38;#38; strcasecmp($inv,&#38;quot;2816&#38;quot;) != 0&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#38;#38;&#38;#38; strcasecmp($inv,&#38;quot;2906&#38;quot;) != 0&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#38;#38;&#38;#38; strcasecmp($inv,&#38;quot;3104&#38;quot;) != 0&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;//Promo code&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#38;#38;&#38;#38; strcasecmp($inv,&#38;quot;9999&#38;quot;) != 0&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;)&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;{&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;$status = &#38;#39;Registration is only open to persons with a valid Promotional code&#38;#39;;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;}&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;else{&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;$status = true;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;}&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;return $status;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;}&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;&#60;code&#62;function form2_hook_tix_validation($user_input){&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;&#60;code&#62;$tix = $user_input[&#38;#39;element_7&#38;#39;];&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;&#60;code&#62;if (&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;strcasecmp($tix,&#38;quot;1&#38;quot;) != 0&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#38;#38;&#38;#38; strcasecmp($tix,&#38;quot;2&#38;quot;) != 0&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#38;#38;&#38;#38; strcasecmp($tix,&#38;quot;3&#38;quot;) != 0&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#38;#38;&#38;#38; strcasecmp($tix,&#38;quot;4&#38;quot;) != 0&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#38;#38;&#38;#38; strcasecmp($tix,&#38;quot;5&#38;quot;) != 0&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;)&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;&#60;code&#62;{&#60;/code&#62;&#60;br /&#62;
   &#60;code&#62;$status = &#38;#39;Max five tickets&#38;#39;;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;}&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;&#60;code&#62;else{&#60;/code&#62;&#60;br /&#62;
   	&#60;code&#62;$status = true;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;}&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;&#60;code&#62;return $status;&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;}&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;So... I can't figure this out?  Help?
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "Form Validation Rules - More than just forced value or email???"</title>
<link>https://www.machform.com/forums/topic/form-validation-rules-more-than-just-forced-value-or-email#post-126</link>
<pubDate>Fri, 19 Oct 2007 05:49:12 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">126@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;To do this you will need to modify two files and add these codes.&#60;br /&#62;
1) Modify &#60;strong&#62;includes/post-functions.php&#60;/strong&#62;, insert the code below into line 772, above the query line.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;//post_validation hook
if(function_exists(&#38;quot;form{$form_id}_hook_post_validation&#38;quot;)){
	$result = call_user_func(&#38;quot;form{$form_id}_hook_post_validation&#38;quot;,$user_input);
	if($result !== true){
		$process_result[&#38;#39;custom_error&#38;#39;] = $result;
	}
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;&#60;code&#62;&#60;/code&#62;&#60;br /&#62;
This code would call our custom validation code after the built-in validation being called.&#60;/p&#62;
&#60;p&#62;2) Modify &#60;strong&#62;hooks/custom_hooks.php&#60;/strong&#62;, add this code:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;function form99_hook_post_validation($user_input){

   $inv = $user_input[&#38;#39;element_1&#38;#39;];

   if ( strcasecmp($inv,&#38;quot;1111&#38;quot;) != 0 &#38;#38;&#38;#38; strcasecmp($inv,&#38;quot;2222&#38;quot;) != 0
   			 &#38;#38;&#38;#38; strcasecmp($inv,&#38;quot;3333&#38;quot;) != 0 &#38;#38;&#38;#38; strcasecmp($inv,&#38;quot;4444&#38;quot;) != 0
   			 &#38;#38;&#38;#38; strcasecmp($inv,&#38;quot;5555&#38;quot;) != 0 ){
   	$status = &#38;#39;Registration is only open to recipients with an authorized promo code.
   					   Please try again or contact XXXX&#38;#39;;
   }else{
   	$status = true;
   }

   return $status;
  }&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;&#60;code&#62;&#60;/code&#62;&#60;br /&#62;
This is our custom validation code.&#60;/p&#62;
&#60;p&#62;In this case my form_id is 99 and my element name is &#60;strong&#62;element_1&#60;/strong&#62;. Simply adjust these to match your form id and element name.&#60;/p&#62;
&#60;p&#62;If those sounds too difficult, send me an email and I'll help you figuring out.
&#60;/p&#62;</description>
</item>
<item>
<title>mpivon on "Form Validation Rules - More than just forced value or email???"</title>
<link>https://www.machform.com/forums/topic/form-validation-rules-more-than-just-forced-value-or-email#post-123</link>
<pubDate>Fri, 19 Oct 2007 04:47:35 +0000</pubDate>
<dc:creator>mpivon</dc:creator>
<guid isPermaLink="false">123@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;I am interested in creating a form with validation logic that checks to see if a user is from a pre-defined (or authorized) list.  &#60;/p&#62;
&#60;p&#62;i.e.:  The code would look something like this:&#60;/p&#62;
&#60;p&#62;if ( strcasecmp($inv,&#34;1111&#34;) != 0 &#38;#38;&#38;#38; strcasecmp($inv,&#34;2222&#34;) != 0 &#38;#38;&#38;#38; strcasecmp($inv,&#34;3333&#34;) != 0 &#38;#38;&#38;#38; strcasecmp($inv,&#34;4444&#34;) != 0 &#38;#38;&#38;#38; strcasecmp($inv,&#34;5555&#34;) != 0 )&#60;/p&#62;
&#60;p&#62;{&#60;br /&#62;
die(&#34;&#38;lt;p align='center'&#38;gt;&#38;lt;font face='Arial' size='3' color='#FF0000'&#38;gt;Registration is only open to recipients with an authorized promo code.  Please try again or contact XXXX. &#38;lt;/font&#38;gt;&#38;lt;/p&#38;gt;&#34;);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;How would THIS be implemented?
&#60;/p&#62;</description>
</item>

</channel>
</rss>
