This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 2
Set a specific llenght for single line text
Started 15 years ago by grisu59 | 3 posts |
-
How can I set a specific lenght for a single line text field?
For example I have the field of country code that is lenght=2 letter
I don't want that will be more space in this fieldIn another case I have a CAP code that is lenght= 5 numbers
I use still a SINGLE LINE TEXT filed because I don't want it as a numberSo I need set lenght = 5 and allow to type in only numbers
How can I do it???
Posted 15 years ago # -
You need to edit "includes/view-functions.php" file to do so, let say you have 2 element id in form 38 with this details :
1. element_1 --> Single text field --> max : 2 Char
2. element_2 --> Single text field --> max : 5 charThen edit your "view-functions.php" and go to around line 40 , you will see this code :
$element_markup = <<<EOT
Put these code above that line
if ($_GET['id'] == 38) { if ($element->id == 1) { $max_length = 'maxlength="2"'; } elseif ($element->id == 2) { $max_length = 'maxlength="5"'; } }
then go to line 51, you will see this code
<input id="element_{$element->id}" name="element_{$element->id}" class="element text {$element->size}" type="text" value="{$element->default_value}" />
replace with this one
<input id="element_{$element->id}" {$max_length} name="element_{$element->id}" class="element text {$element->size}" type="text" value="{$element->default_value}" />
don't forget to change the form id and element id with yours
MachForm Support
Posted 15 years ago # -
I will try your solution but I would like that where is the option SMALL MEDIUM MAXIMUM I could choose a free value (2, 5, 10 or other)
Posted 15 years ago #
Reply
You must log in to post.