Input Radio required Attribute

Definition and Usage

required The attribute sets or returns whether the radio button must be selected before submitting the form.

This attribute reflects the HTML required attribute.

See also:

HTML Reference Manual:HTML <input> required Attribute

Example

Example 1

Determine whether the radio button must be selected before submitting the form:

var x = document.getElementById("myRadio").required;

Try it yourself

Example 2

Set the radio button as a required part of form submission:

document.getElementById("myRadio").required = true;

Try it yourself

Syntax

Return the required attribute:

radioObject.required

Set the required attribute:

radioObject.required = true|false

Attribute value

Value Description
true|false

Specify whether the radio button should be selected before submitting the form.

  • true - A radio button must be selected before submitting the form
  • false - Default. The radio button is not a required part of the form submission

Technical Details

Return Value: Boolean value, returned if a radio button must be selected before submitting the form true; otherwise return false.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support