Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Hiding subform and make filed required


Level 3

Based on a dropdownfield somewhere on the form aText Field must become required and visible and vice versa.

That Text Field is within a Flowed Subform.

If is use a calculation script to make it happen, then i get an error message that the field cannot be empty.

If i use a layout:ready script to make it happen, then it works without an error, but the fields below doesn't flow up (the field isn't excluded from the form)

Can anyone help me please??

14 Replies


Level 10

If you want I can provide you a better validation than Livecycle built-in validation...

That is a problem with Livecycle validation, if a field is mandatory but hidden, it is still required...

So I've built a method that validates all fields in the form which are visible.

This method is really friendly because i've implemented a exception array that you can insert the names of the fields you dont want it to validate if there's any exceptions you want to do

If you have any question you can ask me, i'll be glad to provide help on this workaround

Here is a PDF exemple on how the method works...


The method is in a script object which is activated by the submit or print button at the end


Level 2

I tried viewing your method, but I am unable to.

I have an issue that is similar and you had responded to me with a suggestion, but ever left it for me. haha 

I have a form that is not giving me a message that required fields are null. I have everything set as it should be. I have several 'hidden' fields that I have actions set for them. i.e. if this field is checked, display this field...

I have a submit button, however, I need the 12 fields to display a message if they are still blank once the submit button is pressed.

Any help would be great!!!


Level 10

How can't you see my method? Are you looking in the validate button?

The method in the validate button is a reference to my script object at the bottom of the hierarchy form, objValidate.

If your fields are specifically in a subform, you can send that subform in param[0] and if it contains fields you don't want to validate, just insert the names in the exception table.


Level 2

Sorry. I am unable to view the form on line…

Is it possible that you email it to me? This form I created I just killing me. I just can’t get the message to pop up when required fields are missed and I need to resolve it or find a work around. I am not a programmer by any means, but I am able to understand formulas.

Thank you Magus069,



Level 10

You must download the PDF file on your computer to be able to open it with LiveCycle. The only browser that can open xfa forms without any problem is IE.

Download it, it will be easier and you will be able to open it from LiveCycle Designer.


Level 10

It is working, you must download the PDF when you got it open in your browser...

Then you can open the PDF through LiveCycle Designer..

This is the code in the form.. The following is inside a script object which contains 2 functions

The code shown above is to validate all fields in the form. There is a exception array, which YOU specify which fields you don't want to validate for different reasons.

If you want to have special validation for some fields or you don't want to validate them, you can insert their name inside a exception array to have a successful validation.

When you click the button for validation you should have something like this

This is a workaround to not deal with Adobe LiveCycle Validation built-in because it is not convenient for fields which are hidden. This method is to validate all visible fields.

Hope this helps.

You can still download the form here, to see how I made it in the form and what the exception array stands for.


Level 2

Thank you Magnus. I have the form now and I am going to go through it. I appreciate you sending the info to me and look forward to figuring this one out.

Thanks again,


Teresa Worthley

IS Training Coordinator

LifeLink Foundation

9661 Delaney Creek Blvd

Tampa, FL 33619

O:813-349-6509 x4446

F: 813-349-6981



Level 2
S. Grootendorst  and  Magus069

Thank you for both of your replies. I finally have been able to download the file. (sorry, we're not using crome yet).I will be taking some time to go through the form and the code with it. I think you all for you help and hope to post back soon that all is great and that I have 'mastered it all' HAHAHA

thanks again to all.


Level 1

Hi - If you have not gotten this to work I have a more simple solution than above which will work on the change event of the drop down.

Presuming the form contains a subform with a Drop down with values of Yes and No
and a subform "sfHidden" with a hidden field "hiddenField"

If Yes is selected in the drop down, the hidden field should become visible and mandatory. If No is selected the hidden field should remain hidden or be hidden if changing from Yes value in drop down and should not be mandatory.

On the change event of the drop down put the following script:

if (xfa.event.change == "Yes")
form1.P1.sfHidden.presence = "visible";
form1.P1.sfHidden.hiddenField.presence = "visible";
form1.P1.sfHidden.hiddenField.mandatory = "error";
form1.P1.sfHidden.hiddenField.mandatoryMessage = "This field is required";

else if (xfa.event.change = "No")
form1.P1.sfHidden.hiddenField.mandatory = "";
form1.P1.sfHidden.hiddenField.presence = "hidden";
form1.P1.sfHidden.presence = "hidden";

I used a Submit by Email button to test that my script is working as expected.

You would need to do some additional scripting to have informative messages when the submit button is pressed.


Level 2

I have not been able to get it to work. First of all I do not have sub forms, just drop down fields and fill-in fields. The form the Magus069 sent me is very extensive for someone at my level of programming. I went through it and tried to create my own based on the script, but have not been successful at all.

I understand the above language and formulas, but unfortunately I do not have subforms. I have tried to manipulate the above script, but once again I am not having luck.

Thank you both very much for your input. If one of you is willing, I could send you the form and you could take a look and see what I have done (or not done) to have the results that I am getting.

Thanks again,



Level 10

The code I provided is suppose to save you a lot of work, if you were not able to make it work you can send me your form and I'll take a look.

Also the new code provided by rvanwyk should be working fine, it is just not the best option if you have to do it for more than one field, because you would have to repeat code for each fields, or make a function with the code and send the object through parameters...

The form with the validation script object is suppose to validate the whole form without having 1 field required, it makes all fields required for you, unless you have exceptions in the array.


Level 1

I agree that your script will do all that, but it is a little overwhelming for some of us (me included). I believe it covers the validation part only, does it not?

Teresa - I have sent you a simple form without subforms by email.



Level 10

Hi Ruth,

Yes, the script provided is for validation purposes only. It is highly recommended to use this script of high complexity xfa dynamic forms to avoid Adobe validation problems.

The validation script is to be used by anyone, even someone which is using Action Script could be using this Script Object. It is not asked to understand the code, but only if you know and understand how to use it.

The script which I suggest to use has been brainstormed* (to be tested through all kind of object's properties and to be as mostly light as possible for any form), any unwanted code is not what is needed in validation purpose.

If, for the purpose of validation, it is required to write 100+ lines of code, it is too much to make sure everything is set correctly for the form. The validation script should be able to replace any number of lines to validate a form. The only validation it's executing, is too look for any field which is visible to the user and too check if it is null. With exceptions that the programmer needs to specify, it can be added some other validation as a date chosen in a date field cannot be passed today's date, or a numeric field must be below 'x' value, or a field can be left empty.

If it is too complicated for new programmers to use this script, don't waste your time on trying to understand it, just do it the long way.