JavaScript Element ariaRequired Property

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline
Instance property

What You’ll Learn

Element.ariaRequired is an instance property that reflects the aria-required attribute. Learn the true and false tokens, when to prefer native required, and how to get or set the property from JavaScript—with five examples and try-it labs.

01

Kind

Instance property

02

Type

String

03

Values

true · false

04

Reflects

aria-required

05

Status

Baseline widely

06

Common with

role="textbox"

Introduction

Some form fields are optional. Others must be filled before submit—email, password, or article tags. Assistive technologies need a clear required signal, not only a red asterisk on the screen.

aria-required carries that signal. ariaRequired is the JavaScript reflection of that attribute.

JavaScript
const el = document.getElementById("txtBoxInput");
console.log(el.ariaRequired); // "true"
el.ariaRequired = "false";
💡
Beginner tip (MDN)

Where possible, use an HTML <input type="text"> or a <textarea> with the native required attribute. Prefer ARIA required mainly for custom widgets (for example a role="textbox"). Keep visible labels and validation in sync.

Understanding the Property

MDN: the ariaRequired property of the Element interface reflects the value of the aria-required attribute, which indicates that user input is required on the element before a form may be submitted.

  • Reflected attribute — mirrors aria-required.
  • Get / set — readable and writable string.
  • Two tokenstrue, false.
  • Baseline — widely available since October 2023 (MDN).

📝 Syntax

JavaScript
ariaRequired

Value

A string with one of the following values:

ValueMeaning (MDN)
"true"Users need to provide input before a form is submitted.
"false"User input is not necessary to submit the form.
⚠️
Signal vs validation

ariaRequired announces the requirement. It does not automatically block submit. Use native required, your own checks, and a clear error message when the field is empty.

📋 MDN Example Shape

MDN starts with a contenteditable textbox marked aria-required="true", then updates it to "false":

JavaScript
<div id="txtboxMultilineLabel">Enter the tags for the article</div>
<div
  role="textbox"
  id="txtBoxInput"
  contenteditable="true"
  aria-multiline="true"
  aria-labelledby="txtboxMultilineLabel"
  aria-required="true"
></div>
JavaScript
let el = document.getElementById("txtBoxInput");
console.log(el.ariaRequired); // "true"
el.ariaRequired = "false";
console.log(el.ariaRequired); // "false"

When the field is required, also show a visible cue (for example “required” or an asterisk explained in text) and validate before submit.

⚡ Quick Reference

GoalCode / note
Readel.ariaRequired
Mark requiredel.ariaRequired = "true"
Mark optionalel.ariaRequired = "false"
Prefer when possible<input required> / <textarea required>
Typical rolerole="textbox"
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.ariaRequired.

Kind
get / set

Instance

Type
string

true / false

Reflects
aria-required

Attribute

Baseline
widely

Oct 2023+

Examples Gallery

Examples follow MDN Element: ariaRequired. Labs use a custom textbox so you can safely read and write the property.

📚 Getting Started

Read the reflected value and follow MDN’s update.

Example 1 — Read ariaRequired

Log whether a custom textbox is required.

JavaScript
const el = document.getElementById("txtBoxInput");
console.log(el.ariaRequired);

// HTML includes: role="textbox" aria-required="true"
Try It Yourself

How It Works

The property returns the attribute string. If the attribute is missing, many browsers return null.

Example 2 — MDN Update to "false"

MDN: mark the textbox optional.

JavaScript
let el = document.getElementById("txtBoxInput");
console.log(el.ariaRequired); // "true"
el.ariaRequired = "false";
console.log(el.ariaRequired); // "false"
Try It Yourself

How It Works

Assigning the property updates the reflected aria-required attribute so assistive technologies know whether input is required before submit.

📈 Mark Required, Attribute Sync & Snapshot

Practice required fields and verify reflection.

Example 3 — Set "true" on a Textbox

Create a contenteditable textbox and mark it required.

JavaScript
const box = document.createElement("div");
box.setAttribute("role", "textbox");
box.setAttribute("contenteditable", "true");
box.setAttribute("aria-label", "Article tags");
document.body.appendChild(box);

box.ariaRequired = "true";
console.log({
  ariaRequired: box.ariaRequired,
  attr: box.getAttribute("aria-required")
});
Try It Yourself

How It Works

Pair role="textbox" with a clear accessible name. Prefer <input required> or <textarea required> in real pages when you can.

Example 4 — Property vs getAttribute

Confirm the attribute stays in sync after a write.

JavaScript
const el = document.createElement("div");
el.setAttribute("role", "textbox");
el.setAttribute("contenteditable", "true");
el.setAttribute("aria-required", "true");
el.setAttribute("aria-label", "Tags");
document.body.appendChild(el);

el.ariaRequired = "false";
console.log({
  fromProperty: el.ariaRequired,
  fromAttribute: el.getAttribute("aria-required"),
  same: el.ariaRequired === el.getAttribute("aria-required")
});
Try It Yourself

How It Works

Prefer ariaRequired in script; keep the attribute for HTML markup.

Example 5 — Support Snapshot

Feature-detect and remember the native-control preference.

JavaScript
console.log({
  supported: "ariaRequired" in Element.prototype,
  allowed: ["true", "false"],
  tip: "Prefer input/textarea required when possible (MDN)",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

Use ariaRequired when a custom textbox is required; otherwise lean on native required.

🚀 Common Use Cases

  • Custom textboxes that must be filled before submit.
  • Dynamic forms that toggle required vs optional fields.
  • Design-system inputs that cannot use native required.
  • Multi-step wizards that mark step fields as required.
  • Keeping script and markup aligned without manual setAttribute.

🔧 How It Works

1

You build a form control

Often role="textbox" when native HTML is not used.

Field
2

Set ariaRequired to true or false

Declare whether input is required before submit.

Declare
3

Match visible UI and validation

Show required cues and block empty submits in script.

Enforce
4

Users know the field is required

Assistive tech announces the requirement before submit.

📝 Notes

  • Not Deprecated, Experimental, or Non-standard on MDN (Baseline Widely available).
  • Prefer native required on <input> / <textarea> when possible (MDN).
  • Keep labels, asterisks, and validation aligned with the true / false value.
  • Related: ariaRelevant, ariaReadOnly, ariaRoleDescription, JavaScript hub.

Browser Support

Element.ariaRequired is Baseline Widely available (MDN: across browsers since October 2023). Logos use the shared browser-image-sprite.png sprite from this project.

Baseline Widely available

Element.ariaRequired

String true / false — reflects aria-required for required form input.

Baseline Widely available
Google Chrome Supported (ARIA reflection)
Yes
Microsoft Edge Supported (ARIA reflection)
Yes
Mozilla Firefox Supported (ARIA reflection)
Yes
Apple Safari Supported (ARIA reflection)
Yes
Opera Follow Chromium support
Yes
Internet Explorer No ariaRequired IDL — use setAttribute
No
ariaRequired Baseline

Bottom line: Use ariaRequired on custom widgets to declare required input before submit. Prefer native required when you can. Keep visible cues and validation in sync with the value.

Conclusion

ariaRequired reflects aria-required so custom form widgets can declare that input is required before submit. Prefer native required when possible, and keep visible cues plus validation aligned with the announced token.

Continue with ariaRoleDescription, ariaRelevant, ariaInvalid, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Prefer native required when possible
  • Show a visible required cue, not only ARIA
  • Validate empty fields before submit
  • Update the property when a field becomes optional
  • Give custom textboxes a clear accessible name

❌ Don’t

  • Rely on ariaRequired alone to block submit
  • Skip native controls just to use ARIA
  • Mark required without telling sighted users
  • Leave custom textboxes unnamed
  • Forget error messages when validation fails

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaRequired

Reflected aria-required string for required form input.

5
Core concepts
📝 02

true / false

required vs optional

Values
🔍 03

Prefer native

required attr

MDN
04

Baseline

widely available

Status
🎯 05

Validate too

not signal only

Rule

❓ Frequently Asked Questions

It reflects the aria-required attribute as a string, indicating that user input is required on the element before a form may be submitted.
No. MDN marks Element.ariaRequired as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
The strings "true" (users must provide input before submit) or "false" (input is not necessary to submit the form).
Yes when possible. MDN recommends an HTML input with type="text" or a textarea (with the required attribute) because they have built-in semantics and do not require ARIA attributes.
No. It tells assistive technologies the field is required. You still need visible cues and validation logic (or native required) to enforce the rule.
Yes. Reading and writing ariaRequired updates the reflected aria-required attribute. Keep UI labels and validation behavior in sync with the value.
Did you know?

Native required on an <input> also participates in HTML constraint validation. aria-required on a custom textbox announces the same idea to assistive technologies, but your script still must enforce the rule.

Next: ariaRoleDescription

Learn the reflected aria-roledescription property for custom role wording.

ariaRoleDescription →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful