Input URL disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input URL

Description

The disabled property sets or gets whether a URL field should be disabled.

This property reflects the HTML disabled attribute.

Set the disabled property with the following Values

Value Description
true|false Sets whether a URL field should be disabled

Return Value

A Boolean, returns true if the URL field is disabled, otherwise it returns false

The following code shows how to disable a URL field:

Demo Code

ResultView the demo in separate window

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

<button onclick="disableBtn()">Disable URL Field</button>
<button onclick="enableBtn()">Enable URL Field</button>

<script>
function disableBtn() {/*from   w ww  . j  a v a2s  .c  o  m*/
    document.getElementById("myURL").disabled = true;
}
function enableBtn() {
    document.getElementById("myURL").disabled = false;
}
</script>

</body>
</html>

Related Tutorials