The disabled
property disables or enables a search field.
disabled |
Yes | Yes | Yes | Yes | Yes |
Return the disabled property.
var v = searchObject.disabled
Set the disabled property.
searchObject.disabled=true|false
Value | Description |
---|---|
true|false | Set whether a search field should be disabled
|
A Boolean type value, true if the search field is disabled, otherwise false.
The following code shows how to get if a search field is disabled.
<!DOCTYPE html>
<html>
<body>
Search: <input type="search" id="mySearch" disabled>
<button onclick="myFunction()">test</button>
<!-- w w w . ja v a 2s . c o m-->
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("mySearch").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 search field.
<!DOCTYPE html>
<html>
<body>
<!-- www. j ava 2 s . c o m-->
Search: <input type="search" id="mySearch"><br><br>
<button onclick="disableBtn()">Disable Search Field</button>
<button onclick="enableBtn()">Enable Search Field</button>
<script>
function disableBtn() {
document.getElementById("mySearch").disabled = true;
}
function enableBtn() {
document.getElementById("mySearch").disabled = false;
}
</script>
</body>
</html>
The code above is rendered as follows: