HTMLSelectElement: required property

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{ 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](/en-US/docs/Web/HTML/Reference/Elements/select#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