I propose an extension to the fieldset element: a required attribute. The required attribute is similar to the required attribute of the input element. The attribute can accept an optional valid non-negative integer greater than zero.

If specified, this attribute can determine the number of descendant input elements that are required, potentially overriding the number set indirectly by the number of descendant input elements that have their own required attribute (boolean) assigned. The descendant input elements' required state changes depending upon the presence or absence of a value for this attribute, and if present, the value itself.

If a value for the required attribute is specified, and the value is greater than the number of descendant input elements that have their own required attribute assigned, then the required state of the descendant input elements with a required attribute assigned remain unchanged, and one or more additional descendant input elements that do not have a required attribute assigned will be required, up to the total value assigned. If the value is greater than the actual number descendant input elements, user agents should revise the value down to the actual number. If the value is equal to the acutal number of descendant input elements, then all descendant input elements are considered to have the required state applied, effectively making the required attribute assigned to any individual descendant input elements, redundant.

If a value for the required attribute is specified, and the value is equal to the number of descendant input elements that have their own required attribute assigned, then the value should be ignored by user agents; the behaviour of descendant input elements remain unchanged.

If a value for the required attribute is specified, and the value is less than the number of descendant input elements that have their own required attribute assigned, then only the descendant input elements that have their own required attribute assigned will be checked for values, up to the value assigned. Remaining descendant input elements will not be regarded as required, regardless of whether they have their own required attribute assigned or not.

If a value for the required attribute is not specified, the all descendant input elements are considered to have the required state applied, effectively making the required attribute assigned to any individual descendant input elements, redundant.

It is recommended that this proposed attribute be ignored for input elements of the Radio Button state, when not used in combination with other input element types, as well as any other input elements for which it does not make sense for the proposed required attribute to be used.

Code Example

In this example, there are three Checkbox state input elements within a single fieldset element. None of them been assigned a required attribute (boolean). A required attribute (integer; proposed) has been added to the fieldset element, with a value of '2'.

<fieldset required=2>
 <input name="red" type=checkbox>Red
 <input name="green" type=checkbox>Yellow
 <input name="blue" type=checkbox>Blue
</fieldset>
Although perhaps not a 'real-world' example, this webpage author intends for a secondary colour to be created from at least two of the primary colours that are offered to the user.

Code Example

In this example, there are three Text state input elements within a single fieldset element. None of them been assigned a required attribute (boolean). A required attribute (integer; proposed) has been added to the fieldset element, without a value.

<fieldset required>
 <input name="username" type=text>User name:
 <input name="password" type=text>Password:
 <input name="password2" type=text>Re-enter password:
</fieldset>
Since the text fields relate to setting up a user account, all three fields are required. As there is a required attribute present without a value in the fieldset element, each of the descendant input elements do not require their own required attribute.

Code Example

In this example, there are four Checkbox state input elements within a single fieldset element. None of them been assigned a required attribute (boolean). A required attribute (integer; proposed) has been added to the fieldset element, with a value of '1'.

<fieldset required=1>
 <input name="electrical" type=checkbox>Electrical
 <input name="plumbing" type=checkbox>Plumbing
 <input name="hotwater" type=checkbox>Hot Water
 <input name="gas" type=checkbox>Gas
</fieldset>
The webpage author intends that at least one of the four services offered, be chosen. For each individual checkbox that is ticked, an email will be sent to the department of the relevant service after form submission, notifying them of the customer's intentions.

Code Example

In this example, there are three Text state input elements within a single fieldset element. Two of them have been assigned a required attribute (boolean). A required attribute (integer; proposed) has been added to the fieldset element, with a value of '1'.

<fieldset required=1>
 <input name="phone" type=text required>Phone No.
 <input name="fax" type=text required>Fax No.
 <input name="email" type=text>Email Address
</fieldset>
The user agent should request to the user that either the 'Phone No.' or 'Fax No.' field should be filled in, as the author of the webpage considers that at least one of the two fields must be filled in, to proceed with form submission. The 'Email Address' field is completely optional to the user, as it does not have a required attribute.
Note: Although a single text input field with a 'Contact No.' label could suffice, there may be a requirement to treat a landline or cell phone / mobile phone number differently to a fax number, such as preparing a letter to send via facsimile. Since both numbers are typically very similar, it would be virtually impossible to distinguish between the two different types, thus supporting the requirement of the extra required attribute in the fieldset element. If only one of the two text fields were filled in before submission, the processing script / webpage would receive the type of the field that was used, as well as the number, in a name-value pair.

Code Example

In this example, there are five Text state input elements within a single fieldset element. Two of them have been assigned a required attribute (boolean). A required attribute (integer; proposed) has been added to the fieldset element, with a value of '3'.

<fieldset required=3>
 <input name="name" type=text required>Name
 <input name="address" type=text required>Address
 <input name="phone" type=text>Phone No.
 <input name="fax" type=text>Fax No.
 <input name="email" type=text>Email Address
</fieldset>
The webpage author intends that the first two text input fields are mandatory, while one of the remaining three fields must be filled in. Since the value given with the required attribute is one more than the number of input fields that have their own required attribute, the user agent must ensure that at least one of the three input fields remaining that do not have their own required attribute, are filled in.