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

If a user fills in textbox 1, prompted to complete textbox 2? How to?

slang75
Registered: Apr 22 2009
Posts: 15

Hi,

I have a simple form with text fields, and only two of the fields, if one is filled, I would like the user prompted to complete the other field next to it, and vice versa. If neither is filled no problem, if both filled no problem.

Like this,

If a user fills in textbox 1 prompted to complete textbox 2

If a user fills in textbox 2 prompted to complete textbox 1

Does anyone know how to do this? I do not have a submit button on the form so I think I have to add a validation script?

I am new to this so I apologize, but if anyone could help me that would be great.

Thanks so much,
Jon

My Product Information:
Acrobat Pro 7.0.9, Windows
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi slang75,

Sure, that is certainly doable. If you are new to scripting the best place to start is with the JavaScript for Acrobat API Reference, which you can find with the rest of the SDK documentation at http://www.adobe.com/devnet/acrobat.

Then a good use of your time for learning would be to go to the Learning Center here at AUC and browse through the 70 or so tutorials on using JavaScript in Acrobat and PDFs (select JavaScript in the pulldown for filtering results). There are many sample files included with tutorials so you can examine the code used that is explained in the articles.

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
slang75
Registered: Apr 22 2009
Posts: 15
The only luck I have had thus far is to create a warning message. When a user tabs into the fields.

alert = "Please fill in both values"
app.alert (msg);

But what I would like is that if no data in entered, to not get the warning, and if both fields are filled no warning. How do I do that?

I just need the warning if a user only enters data in 1 of the two text fields.

Thanks,
Jon
slang75
Registered: Apr 22 2009
Posts: 15
How can I use this code posted in a similar topic in my single page form?

Code:
var rgEmptyTest = /^\s*$/;
if(rgEmptyTest.test(event.value))
{ // Field is empty, make other fields not required
this.getField("MyOtherField").required = false;
}
else
{// Field is not empty, make other fields reqired
this.getField("MyOtherField").required = false;
}

Any idea?

Thanks,
Jon