Incidentally, if you were only showing us *part* of the code...only games 1,2,16...and you really want to show *ALL* the games from 1 to 16, then do this:
Code:
function validateTest()
{
var focus_me = null;
var msg = "";
var form = document.forms[0];
for ( var game = 1; game <= 999999; ++game )
{
var rbg = form["game" + game];
if ( rbg == null ) break; // no more games
if ( ! rbg[0].checked && ! rbg[1].checked )
{
msg += rbg[0].value + " vs. " + rbg[1].value + "\n";
focus_me = focus_me || rbg[0];
}
}
if (msg != "")
{
var prefix = "\n WARNING: The following Games(s) were not selected:\n\n";
var suffix = "\nClick OK to submit your picks anyway.\n\n";
+ "\n Click CANCEL to correct your picks."
var ask = confirm(prefix + msg + suffix);
if (ask) {
if (focus_me)
focus_me.focus();
return true;
} else{
return false;
}
}
return true;
}
That actually will handle any number of consecutively numbered games, of course. The loop just stops when no set of numbered radio buttons are found.
I got rid of the functions since, with only two values per radio group, they really aren't needed.