Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Automatic field input & make field required if option 2 is selected.

Avatar

Level 2

Hello all,

In my form I want to create an field where you must fill in you lastname, but in the header of page 2 & 3 , there an field where the last name also must stand.

I've tried and searched for something to create that, but it is not so easy like in microsoft Excel

Does anybody know how I can create somthing like that?

And I have an second question.

I have an group with radio buttons. but if option 2 is selected and text field must be set required and must be open to fill something in that field, if any other option is selected the textfield must me read-only and not required.

The read-only part does work, but the required part doesn't.

Here's my script.


if

(this.rawValue == 2)

{


//Textfield open

     Naam_Partner.acces

= "open";

     Naam_Partner.mandatory

= "error";

}


else


{


//Textfield closed

     Naam_Partner.access

= "readOnly";

     Naam_Partner.rawValue

= null;

}


Greetings,

Timo

5 Replies

Avatar

Level 10

Hi Timo,

To make a field optional, you can use the mandatory property,but sets its value to "disabled";

Naam_Partner.mandatory = "disabled";

Where you want data to be displayed in several places in a form, you give all of the objects the same name in the hierarchy and then set the binding to 'global', in the Object > Binding palette. This will display the same input in all instances.

Hope that helps,

Niall

Assure Dynamics

Avatar

Level 2

Hi Niall,

The automatic field input works really great. But te mandatory option doesn't work.

I have the following script in the click event of the radio buttons.


if

(this.rawValue == 1)

{


//Show field and make required

     Naam_Verzekering.presence

= "visible";

     Naam_Verzekering.mandatory

= "enabled";

     Naam_Verzekering_Onderschrift.presence

= "visible";

}

else

//Hide field and field is not required

{


     Naam_Verzekering.presence

= "invisible";

     Naam_Verzekering.mandatory

= "disabled";

     Naam_Verzekering_Onderschrift.presence

= "invisible";

}


Avatar

Level 10

Hi Timo,

The syntax for making a field required is .mandatory = "error"; (eg not "enabled").

...

Naam_Verzekering.mandatory = "error";

...

Hope that helps,

Niall

Avatar

Level 2

Hi Niall,

The script now works because it cancels my print action. But is it also possible to show a message if the field is empty? I tried the "message from validation script" box, but that doesn't work.

Greetings,

Timo

Avatar

Level 10

Hi Timo,

I have an example here that uses the validationState event and the cancelAction for validation before printing. This means that the target version must be set to v9.1 as a minimum.

http://www.assuredynamics.com/index.php/category/portfolio/print-if-form-passes-validation/

You could use an 'empty message' in the Object > Value palette, instead of validation. Otherwise you would build a custom error message in the prePrint event.

John Brinkman explains the perils of validation against null in this post: http://blogs.adobe.com/formfeed/2009/07/script_validation_vs_null_vali.html

If you can live with a target version of 9.1, then I would run with the Form Validation (validationState) settings in the File > Form Properties tab in LC Designer ES2.

If you can't come back and we will do a v9 and below example.

Niall