How can I set my Radio Button group to be required?

Background

RadioButton is a .NET control that requires the GroupName attribute to associate multiple radio buttons to a group. By default, WorkflowGen does not support form field validation on RadioButton. However, .NET RadioButtonList controls are supported by WorkflowGen’s FORM_FIELD_REQUIRED parameter.

You can put radio buttons in different locations on your webform while RadioButtonList restricts the items to be aligned together.

Solution

For instructions on how to use a CustomValidator control to validate the selection of the RadioButton group, see the How can I use a .NET CustomValidator control in my WorkflowGen web form? article.

The following example checks whether a radio button is checked within a radio button group:

function Validate_RadioButtonGroup(source, arguments)
{
 var ValidateResult = true;
 // buttonGroup refers to document.getElementsByName, not getElementById
 var buttonGroup = document.getElementsByName("[YOUR_RADIOBUTTON_GROUPNAME]");
 for (var i=0; i < buttonGroup.length; i++)
 {
 if (buttonGroup[i].checked)
 {
 // there is a radio button within the group selected
 ValidateResult = true;
 break;
 }
 }
arguments.IsValid = ValidateResult;
}