Back to Content

HTMLSelectElement: required property

files/en-us/web/api/htmlselectelement/required/index.md

latest681 B
Original Source

{{ APIRef("HTML DOM") }}

The required property of the {{DOMxRef("HTMLSelectElement")}} interface specifies that the user must select an option with a non-empty string value before submitting a form. It reflects the {{htmlelement("select")}} element's required attribute.

Value

A boolean.

Examples

js
const selectElement = document.getElementById("fruits");
console.log(selectElement.required);

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{HTMLElement("select")}}
  • {{DOMXref("HTMLSelectElement.validity")}}
  • {{cssxref(":required")}} pseudo-class