X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Input URL maxLength Property

Input URL Object Reference Input URL Object

Example

Get the maximum number of characters allowed in a specific URL field:

var x = document.getElementById("myURL").maxLength;

The result of x will be:

30

Try it yourself »


Definition and Usage

The maxLength property sets or returns the value of the maxlength attribute of a URL field.

The maxLength attribute specifies the maximum number of characters allowed in the URL field.

The default value is 524288.

Tip: To set or return the width of an URL field, in number of characters, use the size property.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The maxLength property is supported in all major browsers.

Note: The <input type="url"> element is not supported in Internet Explorer 9 and earlier versions, or in Safari.


Syntax

Return the maxLength property:

urlObject.maxLength

Set the maxLength property:

urlObject.maxLength=number

Property Values

Value Description
number Specifies the maximum number of characters allowed in the URL field. 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 a URL field:

document.getElementById("myURL").maxLength = "8";

Try it yourself »


Related Pages

HTML reference: HTML <input> maxlength Attribute


Input URL Object Reference Input URL Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook