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

Mutually exclusive text fields

bren1519
Registered: Apr 28 2008
Posts: 27
Answered

Hi,

I have three text fields on my form that I wish to be mutually exclusive. I only want the user to be able to complete one of them. Possible? thx in advance. Brenda

My Product Information:
Acrobat Pro 9.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Do you want data entry in one field to make the other fields inaccessible? Or do you just want validation to flag an error if at least on of the fields is not filled out? What is your workflow with this form?

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]

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

bren1519
Registered: Apr 28 2008
Posts: 27
I would like the 2 other fields to be inaccessable if the one field has data. It would be nice if when they filled out a date in one of the fields that the other date fields are skipped over and tabbing takes them to the next valid field. thx
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Use the Validate event to set the other fields to ReadOnly. The first field filled out wins.

Assuming that this is an AcroForm, the code should look like this.
if(!/^\s*$/.test(event.value)){this.getField("Date2").readonly = true;this.getField("Date3").readonly = true;}else{// Re-Enable on an empty fieldthis.getField("Date2").readonly = false;this.getField("Date3").readonly = false;}

If these fields have a visual appearance, i.e. border and/or background, you can give the user a visual clue that they are enabled/disabled by graying them.

http://www.acrobatusers.com/tutorials/2007/09/js_disabling_fields


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]

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

bren1519
Registered: Apr 28 2008
Posts: 27
Thanks so much!