Input URL maxLength Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input URL

Description

The maxLength property sets or gets the maxlength attribute of a URL field, which sets the maximum number of characters allowed in the URL 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 URL field.

Return Value

A Number, representing the maximum number of characters allowed in the URL field

The following code shows how to get the maximum number of characters allowed in a specific URL field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Homepage: <input type="url" id="myURL">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//  w  w  w . j a  v  a2  s  .co  m
    var v = document.getElementById("myURL").maxLength;
    document.getElementById("demo").innerHTML = v;
}
</script>

</body>
</html>

Related Tutorials