Input URL maxLengthProperties
Example
Get the maximum number of characters allowed in the URL field:
var x = document.getElementById("myURL").maxLength;
xThe output result is:30
Try it Yourself »
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, that is, the number of characters, use thesizeattribute.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the maxLength property.
Note:Internet Explorer or Safari browsers do not support HTML <input> elements using the type="url" attribute.
Syntax
Return the maxLength property:
urlObject.maxLength
Set the maxLength property:
urlObject.maxLength=number
Property 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, indicating 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 Yourself »
Related Pages
HTML Reference:HTML <input> maxlength attribute
Input URL Object Other Extensions