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

Conditional mandatory fields on a LifeCycle form

kn_mxs
Registered: Jun 22 2010
Posts: 7

Hello everyone,

I am new here and relatively new to pdf javascripting, but I've got some decent experience in other programming language.

I am trying to create a fillable pdf form in LC Designer. The form carries subforms and fields which will be visible and mandatory depending on the choice made in a radio button list. Basically I am trying to reproduce the effect one gets when manually chooses "User entry - required". The field becomes border red, if the highlighter is turned on. I've tried different properties, but the field is not becoming bordered red.

Any ideas? I've looked through the xml manual, but without much success with this particular matter.

Thanks,

Marek

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You need the "Form XML Model Reference", its the reference for all the scripting objects.

Each field has a property called "mandatory"

// Not Required
MyField.mandatory = "disabled";

// Set to Required
MyField.mandatory = "error";

This is the null test value that will be used when a submit operation is performed. But if you want to manually control what gets highlighted then you'll need to disable the default highlighting and write the code for it.

You can find out more by searching the forums for the word "mandatory".

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

kn_mxs
Registered: Jun 22 2010
Posts: 7
Thanks Tom.

Yeah, I meant "Form XML Model reference". i found the bits about nullTest and .mandatory, but nothing how to make sure that the red border shows up as well.

So if I understand it correctly, the red rectangle around a field as a sign that the field has been manually chosen to be "User entered - required" has nothing to do when .mandatory property is switched on via javascript? Because I used this property proposed by you, but without any red bordering reflecting that during a preview.

I'll try to do more search on mandatory in the forum.

Thanks,

Marek
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The red border shows up only when the form is submitted. mandatory can be set either manually or with a script, you should see the same behavior either way.

null test highlighting is controled through the app object, which is in the regular JavaScript reference.

app.runtimeHighlight

lots of people have asked about this and there are some threads with full validation scripts.

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

kn_mxs
Registered: Jun 22 2010
Posts: 7
thomp wrote:
The red border shows up only when the form is submitted. mandatory can be set either manually or with a script, you should see the same behavior either way.
That's what I thought too, but that 's not the case on my computer. By default, I have the button "Highlight fields" on which means I see the red border without really submitting, so I expect such functionality from the fields I deem as mandatory via javascript as well.

Anyways, I have to do more reading here, as I can probably figure it out without wasting your time.

Thanks,

Marek
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Toggle the highlight fields on and off to get it to refresh. You can do this from a script by turning app.runtimeHighlight on and off. There is a timing issue though. You may need to use a timer to separate the toggle.

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

kn_mxs
Registered: Jun 22 2010
Posts: 7
The problem is that even I insert javascript line .mandatory = "error" into the radiobuttonlist.change event, even after manually switching "highlight fields" button it doesn't bring the red border around the mandatory field. So it behaves like these two are not inter connected.

I have to try search through the forums as it sounds like someone had to run into this already ...

Thanks for your help.


Marek
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
If you are trying to get the highlight outside of the submit context you'll want to write your own highlighting scirpt anyway.

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