Javascript validation for constructed list in grid

I have a column-based grid question that is set as a numeric for each column. Each cell has a max limit based on a previous question so I can't use Constant Sum However, they don't want me to force a response to every cell, but want the columns to have a minimum total of 1.

This gets a little tricky because the column list and the row lists are constructed and I know missing items in a constructed list can cause issues with the javascript validation. I need help on how to write the javascript validation.

The columns are a constructed list of up to 8 items.

The rows are a constructed list of up to 13 items.

We want each shown column to total to at least 1.

What is the best way to accomplish this? I have it working, but only for column 1

This is what I have so far.


var totmin = 0;

for (var x = 1; x <= [% ListLength(TraitsSelected2022) %]; x++)
{
for (var z = 1; z <= 13; z++)
{
totmin = (Number(SSI_GetValue('Q15_r' + z + '_c' + x )) + totmin);
}

if (totmin < 1)
{
strErrorMessage = 'You must have a total greater than 0 for each column';
}
}

Resolved
9 replies