Textarea requiredProperties

Textarea 对象参考手册Textarea Object


Examples

Detect whether the textarea must be filled in before submitting the form:

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

Try it Yourself »

Definition and Usage

The required attribute is used to set or return whether the textarea element must be filled in before submitting the form.



Browser Support

Attribute
required Yes 10.0 Yes Not supported Yes

Syntax

Return the required attribute:

textareaObject.required

Set the required attribute:

textareaObject.required = true|false


Property Values

Value Description
true|false

Specifies whether the textarea element must be filled in before the form is submitted.

  • true - The textarea element must be filled in before the form is submitted.
  • false - Default. The textarea element does not need to be filled in before the form is submitted.


Technical Details

Return Value: A Boolean value, returns true if the textarea element must be filled in before form submission, otherwise returns false.

More Examples

Example

Set the textarea element to be required before form submission:

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

Try it Yourself »


Textarea 对象参考手册Textarea Object

Other Extensions