HTML DOM Input Search maxLength Property
HTML DOM Input Search maxLength Property
-- Learning is not just about technology, but also about dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
JavaScript Reference
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>
Explore Further
Web Service
Networking Services
Software
Web Design & Development
Computer Science
Programming
Development Tools
Programming Languages
Scripts
Scripting Languages
Input Search maxLength Property
Example
Get the maximum number of characters allowed in the search field:
var x = document.getElementById("mySearch").maxLength;
x output result is:
30
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
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";
Related Pages
HTML Reference: HTML <input> maxlength Attribute
YouTip