docs.rodeo

MDN Web Docs mirror

Element: ariaInvalid property

{{APIRef("DOM")}} 

The ariaInvalid property of the {{domxref("Element")}}  interface reflects the value of the aria-invalid attribute. Relevant for the application, checkbox, combobox, gridcell, listbox, radiogroup, slider, spinbutton, textbox, and tree roles, it indicates to the accessibility API whether the entered value does not conform to the format expected by the application.

If the attribute is not present, or is set to the empty string, assistive technology will treat the value as if it were set to false. If the attribute is present but set to a value other than false, grammar, spelling or the empty string (""), assistive technology treats the value as true. The property reflects the attribute value as set, not as handled by assistive technology.

Value

A string with one of the following values:

Examples

In this example the aria-invalid attribute on the element with an ID of quote is omitted, returning null and treated as false. Using ariaInvalid we update the value to grammar (because there are two errors).

<div id="quote" role="textbox" contenteditable>you are your best thing..</div>
<hr />
<pre id="log"></pre>
const logElement = document.querySelector("#log");
function log(text) {
  logElement.innerText = `${logElement.innerText}${text}\n`;
  logElement.scrollTop = logElement.scrollHeight;
}
const el = document.getElementById("quote");
log(`Initial value: ${el.ariaInvalid}`);
el.ariaInvalid = "grammar";
log(`Updated value: ${el.ariaInvalid}`);

{{EmbedLiveSample("Examples", "", "100")}} 

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN