There are a few check box fields on my form that ask "check all that apply". For this reason I must assign a unique field name to each check box so that they are named sequentially resp1, resp2, etc. I want to check to ensure that the user has checked at least one response from this group. Is there a way to do this?
Sure, you just have to check the fields in sequence, and if the value is not "Off", you can stop looking. For example, if there are ten check boxes in your group, the code might look something like:
// Initialize variable
var bChecked = false;
// Loop through the check boxes
for (var i = 1; i < 11; i += 1) {
if (getField("resp" + i).value !== "Off") {
// Indicate that at least one is checked
bChecked = true;
// No need to keep looking
break;
}
}
// true if at least one is checked, false if none are checked
app.alert(bChecked);
North America
Europe, Middle East and Africa
Asia Pacific