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

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

How to make table cells mandatory when visible


Level 2

I have a form with two hidden subforms. Each subform contains a table with fields that need to be mandatory when visible.

The subforms are hidden or revealed based on a selection from a drop-down list.

I found the below script which works great for making a text field mandatory when visible, but, how do you apply this to cells in a table?

I can't figure it out.

if ("RMC-Fort Lupton-FIRE-DOT" == xfa.event.newText)


    Table.FL.presence = "visible";

    Table.FL.TextField1.mandatory ="error";




    Table.FL.presence = "hidden";

    Table.FL.TextField1.mandatory ="disabled";


if ("RMC-Ault-FIRE-DOT" == xfa.event.newText)


    Table.ALT.presence = "visible";

    Table.ALT.TextField2.mandatory ="error";




    Table.ALT.presence = "hidden";

    Table.ALT.TextField2.mandatory ="disabled";


Thanks in advance!

0 Replies


Level 5


I applied this in a blank new form and it worked fine:

form1.page1.Table1.Row1.Cell1.mandatory = "error";

Are you getting any erros in the Javascript console?


Level 2

Thanks for responding Diego,

I tried it and it works fine, but, what if the table has 27 rows and two mandatory cells in each row?

Is there someway to combine them into one line of script? To do them individually will require 54 lines of script just for one table, assuming one line of script for each mandatory cell. The form I creating will eventually have four hidden tables, each with a similar number of rows.


Level 9


You can use bit of scripting to count the no.of rows and according to that you can loop through them. But before that you need to check the table structure. Can you show the table structure?




Level 2

Hi Bibhu,

Thanks for responding.

Here is the table structure. Rows 1 through 25 are all the same. Each row has two cells with Radio Buttons named "AsFound" and "AsLeft." Both need to be mandatory when visible. If you need more information, let me know.




The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now