The attached form contains three object types - text field, radio button exclusion group and a check box. I added a button that performs global form field validation for nulls (text fields), 0 (check boxes) and empty (exclusion groups), excluding the validate button, the reset form button and the mandatory text field object. The image below depicts the result of checking "yes" in the radio button exclusion group and clicking "Validate". When errors occur "Mandatory Fields" is made visible and populated with an error message.
This is a technique I have used to iterate over a subform on the click event of the "Validate" button and get the fields by class name.
// form1.subform1.validateBtn::click - (JavaScript, client)
form1.subform1.mandatoryFields.rawValue = "";
var errorStr = "";
var oNodes = subform1.nodes;
for (var i=0; i < oNodes.length; i++) {
if (oNodes.item(i).className == "field" || oNodes.item(i).className == "exclGroup") {
// text fields and check boxes are of class "fields"
if (oNodes.item(i).className == "field") {
// tricky checking for null check boxes because the default value is "0" where "0" in a text field may be valid
if (oNodes.item(i).rawValue == null || oNodes.item(i).rawValue == "0") {
// exclude the validation button, the reset button and the mandatory fields text field from the test
if (!(oNodes.item(i).name == "validateBtn" || oNodes.item(i).name == "mandatoryFields" || oNodes.item(i).name == "resetBtn")) {
errorStr = errorStr + oNodes.item(i).name + " is a mandatory field" + "\n";
}
}
}
else {
// radio button exclusion groups are of class "exclGroup"
if (oNodes.item(i).rawValue == "") {
errorStr = errorStr + oNodes.item(i).name + " is a mandatory field" + "\n";
}
}
}
}
if (errorStr != "") {
form1.subform1.mandatoryFields.rawValue = errorStr;
form1.subform1.mandatoryFields.presence = "visible";
}
else {
form1.subform1.mandatoryFields.presence = "hidden";
}
Steve