Acrobat User Community Forums

You are not logged in.     Log in to your AUC account.     Don't have an account? Sign up today

#1 2008-01-04 15:52:29

krjarman
Member
Registered: 2008-01-04
Posts: 0

Form Text Field with character counter

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 Pro 7 / Windows

Offline

 

#2 2008-01-06 11:44:26

pddesigner
Member

Registered: 2007-04-24
Posts: 64

Re: Form Text Field with character counter

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...

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson

AcrobatUsers.com  >>  User Groups • News • Events • Articles • Blogs • How To • Resources • Member Log in