Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Textarea required property

Textarea required property

Textarea Object Reference The Textarea object


Example

Check whether the textarea text area must be filled before submitting the form:

var

x

=

document

.

getElementById

(

"

myTextarea

"

)

.

required

;

Try it »

Definition and Usage

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


Browser support

property
required Yes 10.0 Yes Not supported Yes

Syntax

Return the required attribute:

textareaObject.required

Set the required attribute:

textareaObject.required = true|false


Attribute values

Value Description
true|false

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

  • true - the textarea element must be filled before the form is submitted.
  • false - default. the textarea element does not necessarily need to be filled before the form is submitted.
  • |

    Technical Details

    Return value: Boolean, returns true if the textarea element must be filled 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 »


    Textarea Object Reference The Textarea object