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

pop up box

DavidLindberg
Registered: Mar 6 2009
Posts: 28
Answered

I need to have a pop-up box appear if a word is entered into a field. The field does not have any current javascript. Is it possible for the script to be dormant if the word is not typed into the field?

My Product Information:
Acrobat Pro Extended 9.1.1, Windows
efos
Registered: Jan 8 2009
Posts: 63
add a validation script to that field that checks if (event.value == myTrigger){myPopupFunc()}

I'm pretty sure that only runs if the user modifies that field.
DavidLindberg
Registered: Mar 6 2009
Posts: 28
Im a beginner with Java. Where could I find the code to do a simple box with an ok button?

thanks
efos
Registered: Jan 8 2009
Posts: 63
Go to the FAQ link at the top of this forum and get the js API reference. You'll need this. Look up 'alert' (it is a method of 'app') it makes a standard application pop up dialog.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
The easiest method is the 'app.alert(cMsg, nIcon, nType, cTitle, )'. You will find this under the "App" bookmark.

// code to display an alert boxvar sMsg = "This is my message";var nWarn= 1; // warning iconvar nButton = 0; // OK buttonvar sMyTitle = "Message Title";app.alert({cMsg: sMsg, nIcon: nWarn, nType:  nButton, sTitle: sMyTitle});

A more complex alert using the 'Dialog' object is also available.

Now the big coding challenge will be searching the string a given word. This can be done by creating and array from the inputted text or using the RegExp object to test if a word is in the string.

One could even perform the check through the "custom keystroke" of the format tab and issue the alert when the word in entered.

George Kaiser

DavidLindberg
Registered: Mar 6 2009
Posts: 28
how would i write that custom keystroke script to alert the user that hol or holiday should not be entered on the form?
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Thom Parker has posted [url=http://www.acrobatusers.com/tutorials/text-matching-regular-expressions]Text matching with regular expressions[/url] for a starting place.

George Kaiser

DavidLindberg
Registered: Mar 6 2009
Posts: 28
ok. now i have entered the following text into one form field

"run custom validation script"

var myRegExp = /\W[Hh]oliday\W/;
if(myRegExp.test(myText))
app.alert("holiday hours are calculated automatically in peoplesoft do not enter holiday hours on this paysheet",1)

format>custom>custom keystrokevar myText = " holiday ";

now anything i enter into this field will activate the popup box on entry and exit

thoughts?
efos
Registered: Jan 8 2009
Posts: 63
DavidLindberg wrote:
thoughts?
You're overcomplicating it.

if(event.value.search(/holiday/i)>-1){app.alert("holiday hours are calculated automatically in peoplesoft do not enter holiday hours on this paysheet",1)}

search() will return the first index where it found the string 'holiday' (case insensitive with /i). If it is not found, it returns -1. So if the value is greater than -1: it found it.
DavidLindberg
Registered: Mar 6 2009
Posts: 28
I just put this into the validation script and it works exactly like i want it

var myRegExp = /holiday/i;
if(myRegExp.test(event.value))
app.alert("holiday hours are calculated automatically in peoplesoft do not enter holiday hours on this paysheet",1)

var myRegExp = /hol/i;
if(myRegExp.test(event.value))
app.alert("holiday hours are calculated automatically in peoplesoft do not enter holiday hours on this paysheet",1)

thanks everyone!
madhuprasad
Registered: Jan 16 2008
Posts: 6
Hi

I got a new kind of requirement from my clients that need to fill the form through popup window options.
actual requirement is - when i click a button/textfield, this will generate a popup with multiple options and user will pick one and that will reflect in the form textfield.

I don't know how to create layers and am using Acrobat8, so it would be great if you could help me by creating a sample form with this requirement.

Thanks in advance!!
alexson115
Registered: Jul 5 2009
Posts: 1
Such a very amazing link!


[url=http://simulationpretpersonnel.com][color=#DEDFDF][u]pret personnel[/u][/color][/url]