Javascript examples for DOM HTML Element:Input Search
The disabled property sets or gets whether a search 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 search field should be disabled |
A Boolean, returns true if the search field is disabled, otherwise it returns false
The following code shows how to disable a search field:
<!DOCTYPE html> <html> <body> 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() {/* w w w .j ava2s.co m*/ document.getElementById("mySearch").disabled = true; } function enableBtn() { document.getElementById("mySearch").disabled = false; } </script> </body> </html>