Latest web development tutorials

HTML DOM Input Search maxLength property

Input Search Object Reference Input Search Object

Examples

Get the search field allows you to enter the maximum number of characters:

var x = document.getElementById ( "mySearch") maxLength.;
x The output is:
30

try it"

Definition and Usage

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

maxLength attribute describes the search field allows the maximum number of characters entered.

The default value is 524288.

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


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support maxLength property.


grammar

Back maxLength attributes:

searchObject .maxLength

Setting maxLength properties:

searchObject .maxLength = number

Property Value

value description
number Describes the search field allows you to enter the maximum number of characters, the default is 524288

technical details

return value: Number that represents the maximum search field allows you to enter the number of characters.


More examples

Examples

Modify search field allows you to enter the maximum number of characters:

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

try it"


Related Pages

HTML Reference Manual: HTML <the INPUT> MAXLENGTH property


Input Search Object Reference Input Search Object