The disabled
property disables or enables a URL field.
disabled |
Yes | Yes | Yes | Yes | Yes |
Return the disabled property.
var v = urlObject.disabled
Set the disabled property.
urlObject.disabled=true|false
Value | Description |
---|---|
true|false | Set whether or not a URL field should be disabled
|
A Boolean type value, true if the URL field is disabled, otherwise false.
The following code shows how to check if a URL field is disabled.
<!DOCTYPE html>
<html>
<body>
<!--from w w w . ja v a 2 s.co m-->
Homepage: <input type="url" id="myURL" disabled>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myURL").disabled;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to disable and enable a URL field.
<!DOCTYPE html>
<html>
<body>
<!-- w w w . ja v a 2s . c o m-->
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() {
document.getElementById("myURL").disabled = true;
}
function enableBtn() {
document.getElementById("myURL").disabled = false;
}
</script>
</body>
</html>
The code above is rendered as follows: