You could scan the document.formName.elements() array, check for 'input' type elements and then check their values, but that could be cumbersome. Since you say you'll be grouping some elements, I'd assign the input elements in each group a unique 'class' attribute and use document.getElementsByClassName() to fetch each group quickly and cleanly. From there, it's a matter of what constitutes a valid entry, how many elements belong to each class, and what the desired ratio is.