Input Search maxLength attribute
Definition and Usage
maxLength
Attribute sets or returns the value of the maxlength attribute of the search field.
The HTML maxLength attribute specifies the maximum number of characters allowed in the search field, with a default value of 524288.
Tip:To set or return the width of the search field (in characters), use size attribute.
See also:
HTML Reference Manual:HTML <input>-maxlength-Eigenschaft
Example
Example 1
Get the maximum number of characters allowed in a specific search field:
var x = document.getElementById("mySearch").maxLength;
Example 2
Change the maximum number of characters allowed in the search field:
document.getElementById("mySearch").maxLength = "8";
Syntax
Return maxLength attribute:
searchObject.maxLength
Set maxLength attribute:
searchObject.maxLength = number
Attributwert
Wert | Beschreibung |
---|---|
number | Legt die maximale Anzahl der Zeichen fest, die im Suchfeld erlaubt sind. Standardwert ist 524288. |
Technische Details
Rückgabewert: | Zahl, die die maximale Anzahl der Zeichen angibt, die im Suchfeld erlaubt sind. |
---|
Browser-Unterstützung
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Unterstützung | Unterstützung | Unterstützung | Unterstützung | Unterstützung |