Easy Tutorial
❮ Met Htmlcollection Item Jsref Getutcmonth ❯

Input Search maxLength Attribute

Input Search Object

Example

Get the maximum number of characters allowed in the search field:

var x = document.getElementById("mySearch").maxLength;
30

Definition and Usage

The maxLength attribute is used to set or return the value of the maxlength attribute of the search field.

The maxLength attribute specifies the maximum number of characters allowed in the search field.

The default value is 524288.

Tip: If you need to set or return the length (number of characters) of the search field, use the size attribute.


Browser Support

All major browsers support the maxLength attribute.


Syntax

Return the maxLength attribute:

Set the maxLength attribute:

Attribute Values

Value Description
number Specifies the maximum number of characters allowed in the search field, default is 524288

Technical Details

| Return Value: | A number, representing the maximum number of characters allowed in the search field. | | --- | --- |


More Examples

Example

Change the maximum number of characters allowed in the search field:

document.getElementById("mySearch").maxLength = "8";

Related Pages

HTML Reference: HTML <input> maxlength Attribute


❮ Met Htmlcollection Item Jsref Getutcmonth ❯