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

Field required only if checkbox checked - problem with subforms

Asiante
Registered: Aug 20 2009
Posts: 32

I have a form where some fields are visible only when checkox is checked. Now I want to make some of these fields required.

I used this code for one checkbox and it woks.

if (PD.rawValue==1)

{PDamount.presence = "visible",

PDamount.mandatory = "error";}

else

{PDamount.presence = "invisible",

PDamount.mandatory = "disabled";}

In this case both fields are in one table within one subform. I need to achieve the same result for field in a different subform, I used this code but without effect. Can anyone see my mistake?

if (conference.rawValue==1)

{conferenceform.presence = "visible",

conferenceform.Table5.Row2[0].ConfName.mandatory = "error";}

else

{conferenceform.presence = "hidden",

conferenceform.Table5.Row2[0].ConfName.mandatory = "disabled";}

hcorbin
Registered: Aug 11 2009
Posts: 57
Hello,

I'd like to help but need more information.

1. Which field owns the script? Can you provide its full address e.g. form1.page1.table1.row1.TextField1
2. Where does the other field lives? Also provide full address.

Oh, before I forget, in your script, you have a coma instead of a semi-colon at the end of the line setting the presence.

Thank you,
Hélène
Asiante
Registered: Aug 20 2009
Posts: 32
Hi,

Here are details:


Script is placed in checkbox field.

Checkbox address:

form1.#subform[0].Basic.Row1[1].conference


And here is address of the field I want to make required (ConfName).

form1.#subform[0].conferenceform.Table5.Row2[0].ConfName


Thanks for checking it.
hcorbin
Registered: Aug 11 2009
Posts: 57
Great!

Try the following script on the change event of the check box:

if (this.rawValue == 1) {conferenceForm.Table5.Row2.ConfName.presence = "visible";conferenceForm.Table5.Row2.ConfName.mandatory = "error";}else{conferenceForm.Table5.Row2.ConfName.presence = "invisible",conferenceForm.Table5.Row2.ConfName.mandatory = "disabled";}

It's not always obvious to come up with the correct SOM expression pointing at an object living inside a different subform. However there is an easy way to get this info.

1. Select the object that owns the script
2. Go to the Script Editor, click anywhere then hold the CTRL key down while you move the mouse over the field you want to access, in this case the ConfName field. The cursor will change into an arrow pointing down, click on the field.
3. The SOM expression of the field you clicked on will be written in the Script Editor.

Hope this helps,
Hélène