YouTip LogoYouTip

Prop Search Maxlength

HTML DOM Input Search maxLength Property

HTML DOM Input Search maxLength Property

HTML DOM Input Search maxLength Property

-- Learning is not just about technology, but also about dreams!

JavaScript Reference

Overview

JavaScript Objects

JavaScript Array Object JavaScript Boolean Object JavaScript Date Object JavaScript Math Object JavaScript Number Object JavaScript String Object JavaScript RegExp Object JavaScript Global Properties/Functions JavaScript Operators JavaScript Error

Browser Objects

Window Object Navigator Object Screen Object History Object Location Object Storage Object

DOM Objects

HTML DOM Document Object HTML DOM Element Object HTML DOM Attribute Object HTML DOM Event Object HTML DOM Console Object CSSStyleDeclaration Object DOM HTMLCollection

HTML Objects

<a> <area> <audio> <base> <blockquote> <body> <button> <canvas> <col> <colgroup> <datalist> <del> <details> <dialog> <embed> <fieldset> <form> <iframe> <frameset > <img> <ins> <input> - button <input> - checkbox <input> - color <input> - date <input> - datetime <input> - datetime-local <input> - email <input> - file <input> - hidden <input> - image <input> - month <input> - number <input> - range <input> - password <input> - radio <input> - reset <input> - search <input> - submit <input> - text <input> - time <input> - url <input> - week <keygen> <link> <label> <legend> <li> <map> <menu> <menuItem> <meta> <meter> <object> <ol> <optgroup> <option> <param> <progress> <q> <script> <select> <source> <style> <table> <td> <th> <tr> <textarea> <title> <time> <track> <video>

HTML DOM Reset Object

HTML DOM Submit Object

Explore Further

Web Service

Networking Services

Software

Web Design & Development

Computer Science

Programming

Development Tools

Programming Languages

Scripts

Scripting Languages

Input Search maxLength Property

Input Search Object Reference Input Search Object

Example

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

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

x output result is:

30

Try it yourself Β»


Definition and Usage

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

The maxLength property describes the maximum number of characters allowed in the search field.

The default value is 524288.

Tip: To set or return the length (number of characters) of the search field, use the size property.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

The maxLength property is supported by all major browsers.


Syntax

Return the maxLength property:

searchObject.maxLength

Set the maxLength property:

searchObject.maxLength=number

Property Values

Value Description
number Describes 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";

Try it yourself Β»


Related Pages

HTML Reference: HTML <input> maxlength Attribute


Input Search Object Reference Input Search Object

← Prop Search ReadonlyProp Search Name β†’