Javascript examples for DOM HTML Element:Input Search
The maxLength property sets or gets the maxlength attribute of a search field.
The default value is 524288.
Set the maxLength property with the following Values
Value | Description |
---|---|
number | Sets the maximum number of characters allowed in the search field. |
A Number, representing the maximum number of characters allowed in the search field
The following code shows how to get the maximum number of characters allowed in a specific search field:
<!DOCTYPE html> <html> <body> Search: <input type="search" id="mySearch"> <p id="demo"></p> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from w w w .j a v a 2s.co m var v = document.getElementById("mySearch").maxLength; document.getElementById("demo").innerHTML = v; } </script> </body> </html>