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

Script to make a textfield required field at run time

Boon
Registered: May 5 2010
Posts: 66
Answered

Hello,

I have a textfield (call it Textfield1) that is setup as non-mandatory field. When I open the form in preview, and highlight the field, there is no red border. (the red border appears on the fields that are set to be required field.)

I would like to create a button. when a user click on the button, it will make the Textfield1 as a required field. and thus, a user will see a red border on the Textfield1.

I appreciate your help.

thanks,
Boon

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
In a LiveCycle form a field is made required with the "mandatory" propertly. There have been many posts on this topic. Search the forms for "mandatory". You'll find plenty.

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

Boon
Registered: May 5 2010
Posts: 66
Thomp,

thanks for your guidance! I am able to do it now. But, I notice that the field that I want it to be mandatory does not have a red boder immediately. I need to click on that field, or scroll the form, after that I will see the red border.

Do I need to do have a script that refresh, or repaint for that field?

thanks,
Boon
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, it needs to be refreshed. But this action is not reliable. Acrobat highlights the fields when the form is submitted. Otherwise it's tricky. There is an AcroForm property for turning the required field highlighing on and off. You might try toggling this property:

app.runtimeHighlight = false;
app.runtimeHighlight = true;

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