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

Text field prepend append

djfixxx
Registered: Mar 22 2007
Posts: 111

Is it possible to add a character to a fillable text field? for instance a text filed asks for name so they type John, I want to have a < or something added to that field on a var this.getField command.

It professional, networking, technical, graphical, imaging, froms.

My Product Information:
Acrobat Pro 8.0999999999999996447286321199499070644378662109375, Windows
pddesigner
Registered: Jul 9 2006
Posts: 858
Add a text field(textInput) and add a button(btnAsk)

Change the cQuestion and cTitle with your question and title.

var t = this.getField("textInput"); // the target field
var cResponse = app.response({
cQuestion: "What do you like about Acrobat?",
cTitle: "Favorite Acrobat feature!"});
{
if ( cResponse == null)
app.alert("Please complete the question."); // if Cancel is selected
else
app.alert("You responded, \""+cResponse+"\", is this correct?",2);
}
t.value = cResponse; // places the data from the dialog to the target field
}Second option:

Create a button(btnQuestion) and text field (UserName). Modify the code to add the special character.

Add this Javascript to the buttons Mouse Up action:
// Dialog Definition
var oDlg =
{
strName: "",
initialize: function(dialog)
{
dialog.load({"usnm":this.strName});
},
commit: function(dialog)
{
var data = dialog.store();
this.strName = data["usnm"];
},
description:
{
name: "Test Dialog",
elements:
[
{
type: "view",
elements:
[
{
name: "Enter your name:",
type: "static_text",
},
{
item_id: "usnm",
type: "edit_text",
char_width: 15
},
{
type: "ok_cancel",
},
]
},
]
}
};
// Dialog Activation
oDlg.strName = this.getField("UserName").value;
if("ok" == app.execDialog(oDlg))
{
this.getField("UserName").value = oDlg.strName;
}

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