These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Form Text Field with character counter

krjarman
Registered: Jan 4 2008
Posts: 4

I have Adobe Acrobat 7.0 Professional and LifeCycle Designer 7.0. I am using LifeCycle to import a WORD document in to create a form. I am trying to create a text field where the user would enter a description of their event in regular paragraph format but limited them to a maximum of only 210 characters including spaces and punctuation, etc. To enable the user to gauge their text, I would like to present them with a count of remaining characters as they type their story.
 
Please tell me if this is possible and if so how to do it.
 
Ken Jarman

My Product Information:
LiveCycle Designer, Windows
pddesigner
Registered: Jul 9 2006
Posts: 858
This solution is offered for an AcroForm (Acrobat Form). The code can be modified for a LiveCycle form. As for as the visual character counter, I've not found a script that will show remaining characters however, I've included an HTML solution that you may be able to modify.
Example 1

Set a limit on the number of characters that can be typed into a field.

var f = this.getField("myText");
f.charLimit = 210;

Example 2

1. Open the Text field properties on a field.

2. Click the Format tab.

3. Click the Custom Keystroke Script radio button.

4. Click Edit and add the following script in the JavaScript Editor.

var f = this.getField("myField");
if (event.value.length > 210)
{
var msg = "Your entry is too long
(limit 210 chars).";
app.alert(msg);
}


+++++++++++++++++++++++++++++++++++
HTML solution code - Between the Head tags:



maxL=210;
function taLimit(taObj) {
if (taObj.value.length==maxL) return false;
return true;
}


function taCount(taObj,Cnt) {
objCnt=createObject(Cnt);
objVal=taObj.value;
if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
if (objCnt) objCnt.innerText=maxL-objVal.length;
return true;
}
function createObject(objId) {
if (document.getElementById) return document.getElementById(objId);
else if (document.layers) return eval("document." + objId);
else if (document.all) return eval("document.all." + objId);
else return eval("document." + objId);
}


++++++++++++++++++++++++++++++++++++++++++++

Between the body tag:

Maximum Number of characters for this text box is 210.

You have 210 characters remaining
for your event description...

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.