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

Making a text field required based on a combo box selection

lschaffer
Registered: Oct 30 2009
Posts: 5

I'm new to Acrobat and to Javascript and am having trouble figuring something out. I want to make a text field required based on a selection from a combo box. For example, I have a combo box with 5-6 selections for a change in job (Promotion, Demotion, other, etc.). Next to the combo box I have a text field. In there, I need the people filling out the form to briefly explain the job change if "Other" was selected from the combo box. How can I make this required?? I'm assuming I can use Javascript in the field properties somewhere. Code examples would be helpful...suggestions would be welcome.

My Product Information:
Acrobat Pro 9.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The easist thing to do is to use a Validation script, and make sure the Combobox is set to "Commit Selection Immediately".

The script should be something like this:

switch(event.value)
{
case "Promotion":
this.getField("MyText").required = true;
break;
.... etc ....
}

If you are not familiar with Scripting or Acrobat JavaScript I would suggest you read/watch some of the entry level material on this site and here:
http://www.pdfscripting.com/public/34.cfm

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script