<?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: Limit field characters</title>
<link>https://www.machform.com/forums/</link>
<description>MachForm Community Forums Topic: Limit field characters</description>
<language>en</language>
<pubDate>Wed, 03 Jun 2026 19:21:43 +0000</pubDate>

<item>
<title>Marconi on "Limit field characters"</title>
<link>https://www.machform.com/forums/topic/limit-field-characters#post-10486</link>
<pubDate>Thu, 16 Sep 2010 06:03:18 +0000</pubDate>
<dc:creator>Marconi</dc:creator>
<guid isPermaLink="false">10486@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;How do I do this for multiple fields, but not all of the same type?  For example, I have some number fields that I want to restrict to 2 numbers, others I want to restrict to 3.
&#60;/p&#62;</description>
</item>
<item>
<title>kdy on "Limit field characters"</title>
<link>https://www.machform.com/forums/topic/limit-field-characters#post-9084</link>
<pubDate>Tue, 30 Mar 2010 18:50:34 +0000</pubDate>
<dc:creator>kdy</dc:creator>
<guid isPermaLink="false">9084@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi there,&#60;/p&#62;
&#60;p&#62;I am having som problems with this one.&#60;br /&#62;
It seems that this solution is only working for &#34;text&#34; elements, but not &#34;textareas&#34;?&#60;br /&#62;
I have a template ID 25 with element ID 9 where I need to limit characters to 160.&#60;/p&#62;
&#60;p&#62;I have tried replacing the &#34;$element_markup&#34; code with the one supplied by you.&#60;br /&#62;
It works fine on element id 1 in my form, which is a text element. But when I change to element 9, which is a textarea, nothing happens?&#60;/p&#62;
&#60;p&#62;Could you please help me?
&#60;/p&#62;</description>
</item>
<item>
<title>redityo on "Limit field characters"</title>
<link>https://www.machform.com/forums/topic/limit-field-characters#post-6917</link>
<pubDate>Thu, 13 Aug 2009 22:46:45 +0000</pubDate>
<dc:creator>redityo</dc:creator>
<guid isPermaLink="false">6917@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I see... advance embed code have different approach indeed. I think the easy way by editing &#34;includes/post-functions.php&#34; file to set a maximum input validation, so when the user input exceed maximum length, it'll show the error. To do so, go to around line 165 and you will see this code :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;$rules[$element_name][&#38;#39;max&#38;#39;] 		= 255;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;put these code exactly bellow that line &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($form_id == 4 )
{
	if ($element_id == 9 &#124;&#124; $element_id == 10)
		$rules[$element_name][&#38;#39;max&#38;#39;] 		= 4;
	elseif ($element_id == 19)
		$rules[$element_name][&#38;#39;max&#38;#39;] 		= 16;

}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Otherwise you can change my previous code, by adding a session variable in your PHP page. Add these code to your PHP page after &#34;&#38;lt;?php&#34;&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;@session_start();
$_SESSION[&#38;#39;sess_form_id&#38;#39;] = 12;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;then change my previous code from :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($_GET[&#38;#39;id&#38;#39;] == 2)
	$set_max = &#38;#39;maxlength=&#38;quot;8&#38;quot;&#38;#39;;
else
	$set_max = &#38;#39;&#38;#39;;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;to&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($_SESSION[&#38;#39;sess_form_id&#38;#39;] == 2)
	$set_max = &#38;#39;maxlength=&#38;quot;8&#38;quot;&#38;#39;;
else
	$set_max = &#38;#39;&#38;#39;;&#60;/code&#62;&#60;/pre&#62;</description>
</item>
<item>
<title>nunya on "Limit field characters"</title>
<link>https://www.machform.com/forums/topic/limit-field-characters#post-6913</link>
<pubDate>Thu, 13 Aug 2009 12:42:41 +0000</pubDate>
<dc:creator>nunya</dc:creator>
<guid isPermaLink="false">6913@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Here's a question: I am integrating my form (id = 4) using the Advanced Code method (which does a php include), so the above code does not work because it is trying to $_GET the form ID and element ID from the url. My question is how can I limit the characters in a field when using the Advanced Code Form method?&#60;/p&#62;
&#60;p&#62;My form id is 4. I would like to limit element_id 9 and 10 to 4 characters and element_id 19 to 16 characters.&#60;/p&#62;
&#60;p&#62;Thank you!!
&#60;/p&#62;</description>
</item>
<item>
<title>redityo on "Limit field characters"</title>
<link>https://www.machform.com/forums/topic/limit-field-characters#post-6466</link>
<pubDate>Fri, 03 Jul 2009 10:38:58 +0000</pubDate>
<dc:creator>redityo</dc:creator>
<guid isPermaLink="false">6466@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;Have you change the form id and element id with yours in these code ?&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($_GET[&#38;#39;id&#38;#39;] == 1 &#38;#38;&#38;#38; $element-&#38;gt;id == 1)
			$set_max = &#38;#39;maxlength=&#38;quot;8&#38;quot;&#38;#39;;
		else
			$set_max = &#38;#39;&#38;#39;;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Anyway if you need to apply the code in all text field on form 2 for example, you can change those condition to be like this :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($_GET[&#38;#39;id&#38;#39;] == 2)
			$set_max = &#38;#39;maxlength=&#38;quot;8&#38;quot;&#38;#39;;
		else
			$set_max = &#38;#39;&#38;#39;;&#60;/code&#62;&#60;/pre&#62;</description>
</item>
<item>
<title>kmac on "Limit field characters"</title>
<link>https://www.machform.com/forums/topic/limit-field-characters#post-6461</link>
<pubDate>Thu, 02 Jul 2009 23:03:06 +0000</pubDate>
<dc:creator>kmac</dc:creator>
<guid isPermaLink="false">6461@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I've used the above code to set the character limit to 50 for a text area but it still allows the input of more characters.&#60;/p&#62;
&#60;p&#62;Also, I have a number of text areas in my form that must be limited to 50 characters. Is there a way that I could have a default set for all text areas in form_1 for instance?&#60;/p&#62;
&#60;p&#62;Many thanks
&#60;/p&#62;</description>
</item>
<item>
<title>Calan on "Limit field characters"</title>
<link>https://www.machform.com/forums/topic/limit-field-characters#post-5933</link>
<pubDate>Thu, 21 May 2009 18:45:44 +0000</pubDate>
<dc:creator>Calan</dc:creator>
<guid isPermaLink="false">5933@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Excellent. Thanks Redityo.
&#60;/p&#62;</description>
</item>
<item>
<title>redityo on "Limit field characters"</title>
<link>https://www.machform.com/forums/topic/limit-field-characters#post-5924</link>
<pubDate>Thu, 21 May 2009 08:45:23 +0000</pubDate>
<dc:creator>redityo</dc:creator>
<guid isPermaLink="false">5924@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;To set the limit you need to edit &#34;includes/view-functions.php&#34;, for example you want to limit &#34;Text Field&#34; with element id = 1 in form 1, then go around line 40 ~ 50, you will see this code :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;$element_markup = &#38;lt;&#38;lt;&#38;lt;EOT
		&#38;lt;li id=&#38;quot;li_{$element-&#38;gt;id}&#38;quot; {$error_class}&#38;gt;
		&#38;lt;label class=&#38;quot;description&#38;quot; for=&#38;quot;element_{$element-&#38;gt;id}&#38;quot;&#38;gt;{$element-&#38;gt;title} {$span_required}&#38;lt;/label&#38;gt;
		&#38;lt;div&#38;gt;
			&#38;lt;input id=&#38;quot;element_{$element-&#38;gt;id}&#38;quot; name=&#38;quot;element_{$element-&#38;gt;id}&#38;quot;
class=&#38;quot;element text {$element-&#38;gt;size}&#38;quot; type=&#38;quot;text&#38;quot;
 value=&#38;quot;{$element-&#38;gt;default_value}&#38;quot; /&#38;gt;
		&#38;lt;/div&#38;gt;{$guidelines} {$error_message}
		&#38;lt;/li&#38;gt;
EOT;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;replace the code with this one&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($_GET[&#38;#39;id&#38;#39;] == 1 &#38;#38;&#38;#38; $element-&#38;gt;id == 1)
			$set_max = &#38;#39;maxlength=&#38;quot;8&#38;quot;&#38;#39;;
		else
			$set_max = &#38;#39;&#38;#39;;

$element_markup = &#38;lt;&#38;lt;&#38;lt;EOT
		&#38;lt;li id=&#38;quot;li_{$element-&#38;gt;id}&#38;quot; {$error_class}&#38;gt;
		&#38;lt;label class=&#38;quot;description&#38;quot;
for=&#38;quot;element_{$element-&#38;gt;id}&#38;quot;&#38;gt;{$element-&#38;gt;title} {$span_required}&#38;lt;/label&#38;gt;
		&#38;lt;div&#38;gt;
			&#38;lt;input {$set_max}  id=&#38;quot;element_{$element-&#38;gt;id}&#38;quot; name=&#38;quot;element_{$element-&#38;gt;id}&#38;quot;
class=&#38;quot;element text {$element-&#38;gt;size}&#38;quot; type=&#38;quot;text&#38;quot;
 value=&#38;quot;{$element-&#38;gt;default_value}&#38;quot; /&#38;gt;
		&#38;lt;/div&#38;gt;{$guidelines} {$error_message}
		&#38;lt;/li&#38;gt;
EOT;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;those code will limit text field size to 8
&#60;/p&#62;</description>
</item>
<item>
<title>Calan on "Limit field characters"</title>
<link>https://www.machform.com/forums/topic/limit-field-characters#post-5912</link>
<pubDate>Wed, 20 May 2009 20:58:58 +0000</pubDate>
<dc:creator>Calan</dc:creator>
<guid isPermaLink="false">5912@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Pleas explain how I would limit the number of characters allowed in a field. I need to limit certain fields to say 6 or 8 numbers.&#60;/p&#62;
&#60;p&#62;Thanks.
&#60;/p&#62;</description>
</item>

</channel>
</rss>
