<?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: Validating U.S. Zip Code for Zip +4</title>
<link>https://www.machform.com/forums/</link>
<description>MachForm Community Forums Topic: Validating U.S. Zip Code for Zip +4</description>
<language>en</language>
<pubDate>Sun, 03 May 2026 20:58:56 +0000</pubDate>

<item>
<title>NickJ on "Validating U.S. Zip Code for Zip +4"</title>
<link>https://www.machform.com/forums/topic/validating-us-zip-code-for-zip-4#post-24668</link>
<pubDate>Sat, 09 Jan 2016 01:46:32 +0000</pubDate>
<dc:creator>NickJ</dc:creator>
<guid isPermaLink="false">24668@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;For anyone else interested, the code above works if you build the address fields individually on the form and not use the built in address field.  That allows the variable $zip_code_element_id to be compared to a digit without the underscore.  Thanks for the assist, yuniar.
&#60;/p&#62;</description>
</item>
<item>
<title>NickJ on "Validating U.S. Zip Code for Zip +4"</title>
<link>https://www.machform.com/forums/topic/validating-us-zip-code-for-zip-4#post-24649</link>
<pubDate>Mon, 04 Jan 2016 22:49:42 +0000</pubDate>
<dc:creator>NickJ</dc:creator>
<guid isPermaLink="false">24649@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;ping
&#60;/p&#62;</description>
</item>
<item>
<title>fla56 on "Validating U.S. Zip Code for Zip +4"</title>
<link>https://www.machform.com/forums/topic/validating-us-zip-code-for-zip-4#post-24615</link>
<pubDate>Sun, 27 Dec 2015 00:31:46 +0000</pubDate>
<dc:creator>fla56</dc:creator>
<guid isPermaLink="false">24615@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi Yuniar, hi guys, thanks for the code, I've been able to modify it to help me build domain-specific email validation but I need a little more help with this:&#60;/p&#62;
&#60;p&#62;if($form_id == 66389){ $email_element_id = 9;  if (!preg_match(&#34;/&#34;.&#34;^([a-z0-9]+(?!.*(?:\+{2,}&#124;\-{2,}&#124;\.{2,}))(?:[\.+\-]{0,1}[a-z0-9])*@nhs.net&#124;[a-z0-9]+(?!.*(?:\+{2,}&#124;\-{2,}&#124;\.{2,}))(?:[\.+\-]{0,1}[a-z0-9])*@.*\.nhs\.uk)$&#34;.&#34;/&#34;,$user_input['element_'.$email_element_id])){ $error_elements[$email_element_id] = 'Non-NHS email. Please enter a valid address.'; } }&#60;/p&#62;
&#60;p&#62;I really need to be able to do this for any/all forms and any/all email fields, ideally on a per-field basis (and for machform logins), any ideas?&#60;/p&#62;
&#60;p&#62;Thanks in advance.&#60;/p&#62;
&#60;p&#62;David
&#60;/p&#62;</description>
</item>
<item>
<title>NickJ on "Validating U.S. Zip Code for Zip +4"</title>
<link>https://www.machform.com/forums/topic/validating-us-zip-code-for-zip-4#post-24609</link>
<pubDate>Thu, 24 Dec 2015 03:21:17 +0000</pubDate>
<dc:creator>NickJ</dc:creator>
<guid isPermaLink="false">24609@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Thanks.  Having some issues with implementing this.  The source code is showing the Zip Code to be element_6_5.  I've tried the following iterations with no luck:&#60;/p&#62;
&#60;p&#62;$zip_code_element_id = 6;&#60;br /&#62;
$zip_code_element_id = &#34;6_5&#34;;&#60;br /&#62;
$zip_code_element_id = 6_5;&#60;br /&#62;
$zip_code_element_id = 5;&#60;/p&#62;
&#60;p&#62;Thanks.
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "Validating U.S. Zip Code for Zip +4"</title>
<link>https://www.machform.com/forums/topic/validating-us-zip-code-for-zip-4#post-24599</link>
<pubDate>Mon, 21 Dec 2015 11:26:25 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">24599@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Let say you have a form with id number 12629 and the text field you're using for the zip code is having id number 1 (check the html source of your form to see it).&#60;/p&#62;
&#60;p&#62;You can edit your &#34;machform/includes/post-functions.php&#34; file. Search around line 452 for this code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;$error_elements = array();
$table_data = array();&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;below that block of code, add this code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if($form_id == 12629){
    $zip_code_element_id = 1;

    if (!preg_match(&#38;quot;/&#38;quot;.&#38;quot;^\d{5}([\-]?\d{4})?$&#38;quot;.&#38;quot;/i&#38;quot;,$user_input[&#38;#39;element_&#38;#39;.$zip_code_element_id])){
	$error_elements[$zip_code_element_id] = &#38;#39;Incorrect zip code&#38;#39;;
	}
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;That should do it.&#60;br /&#62;
Just make sure to adjust the above form id number and the zip code field number with your own.
&#60;/p&#62;</description>
</item>
<item>
<title>celsiusmarketing on "Validating U.S. Zip Code for Zip +4"</title>
<link>https://www.machform.com/forums/topic/validating-us-zip-code-for-zip-4#post-24545</link>
<pubDate>Fri, 11 Dec 2015 00:25:41 +0000</pubDate>
<dc:creator>celsiusmarketing</dc:creator>
<guid isPermaLink="false">24545@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;You could validate zip code with jquery / javascript through regular expression.
&#60;/p&#62;</description>
</item>
<item>
<title>Saghalie on "Validating U.S. Zip Code for Zip +4"</title>
<link>https://www.machform.com/forums/topic/validating-us-zip-code-for-zip-4#post-24541</link>
<pubDate>Thu, 10 Dec 2015 23:12:03 +0000</pubDate>
<dc:creator>Saghalie</dc:creator>
<guid isPermaLink="false">24541@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Perhaps send an email to support?  Especially since this hasn't been answered in a while.  If and when you do get a response, please post it here!&#60;/p&#62;
&#60;p&#62;Regards,&#60;/p&#62;
&#60;p&#62;Saghalie&#60;br /&#62;
&#60;a href=&#34;http://www.kcmhosting.com&#34; rel=&#34;nofollow&#34;&#62;http://www.kcmhosting.com&#60;/a&#62;
&#60;/p&#62;</description>
</item>
<item>
<title>NickJ on "Validating U.S. Zip Code for Zip +4"</title>
<link>https://www.machform.com/forums/topic/validating-us-zip-code-for-zip-4#post-24538</link>
<pubDate>Thu, 10 Dec 2015 21:31:13 +0000</pubDate>
<dc:creator>NickJ</dc:creator>
<guid isPermaLink="false">24538@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Ping.&#60;br /&#62;
Any help would be greatly appreciated.
&#60;/p&#62;</description>
</item>
<item>
<title>christiansweatt on "Validating U.S. Zip Code for Zip +4"</title>
<link>https://www.machform.com/forums/topic/validating-us-zip-code-for-zip-4#post-24366</link>
<pubDate>Tue, 17 Nov 2015 02:03:13 +0000</pubDate>
<dc:creator>christiansweatt</dc:creator>
<guid isPermaLink="false">24366@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I'd also be very interested in this, if you find the answer!&#60;br /&#62;
Perhaps something that could be easily implemented as an optional feature (checkbox item) for the address field in future versions?
&#60;/p&#62;</description>
</item>
<item>
<title>NickJ on "Validating U.S. Zip Code for Zip +4"</title>
<link>https://www.machform.com/forums/topic/validating-us-zip-code-for-zip-4#post-24343</link>
<pubDate>Thu, 12 Nov 2015 23:48:25 +0000</pubDate>
<dc:creator>NickJ</dc:creator>
<guid isPermaLink="false">24343@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Forgot to add, I'm working with version 4.6.
&#60;/p&#62;</description>
</item>
<item>
<title>NickJ on "Validating U.S. Zip Code for Zip +4"</title>
<link>https://www.machform.com/forums/topic/validating-us-zip-code-for-zip-4#post-24342</link>
<pubDate>Thu, 12 Nov 2015 23:08:07 +0000</pubDate>
<dc:creator>NickJ</dc:creator>
<guid isPermaLink="false">24342@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I've found some documentation on this in the Forum, but the posts are 6 years old and it appears the code has changed significantly.  I'd like to validate the U.S. Zip Code to include 5 digits plus the optional +4.  Could you point me in the right direction?  Any help is appreciated!
&#60;/p&#62;</description>
</item>

</channel>
</rss>
