Textarea required attribute

Definition and Usage

required Sets or returns whether the text area must be filled out before submitting the form.

This attribute reflects the HTML required attribute.

See also:

HTML Reference Manual:HTML <textarea> required Attribute

Instance

Example 1

Determine whether the text area must be filled out before submitting the form:

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

Try it yourself

Example 2

Set the text area as a required part of the form submission:

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

Try it yourself

Syntax

Return the required attribute:

textareaObject.required

Set the required attribute:

textareaObject.required = true|false

Attribute value

Value Description
true|false

The text area should be a required part of the form submission.

  • true - The text area is a required part of the form submission
  • false - Default. The text area is not a required part of the form submission

Technical Details

Return value: Boolean value, returned if the text area is a required part of the form submission true; otherwise return false.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supported 10.0 Supported Not Supported Supported