Input URL maxLength property
Example
Get the maximum number of characters allowed in the URL field:
var x = document.getElementById("myURL").maxLength;
x
The output is:
30
Try it »
Definition and Usage
The maxLength property is used to set or return the maxlength attribute of the URL field.
The maxLength property describes the maximum number of characters allowed in the URL field.
The default value is 524288.
Tip: If you need to set the length of the URL, i.e. the number of characters, please use size attribute.
Browser support





All major browsers support the maxLength property
Note: Internet Explorer or Safari browsers do not support HTML that uses the type="url" attribute. .
Syntax
Return the maxLength property:
urlObject
.maxLength
Set the maxLength property:
urlObject
.maxLength=
number
Attribute values
| Value | Description |
|---|---|
| number | Describes the maximum number of characters allowed in the URL field. The default value is 524288 |
Technical Details
| Return Value: | A number representing the maximum number of characters allowed in the URL field. |
|---|
More examples
Example
Set the maximum number of characters allowed in the URL field:
document.getElementById("myURL").maxLength = "8";
Try it »
Related pages
HTML Reference Manual: HTML maxlength property
The Input URL object