Disable a search field:
document.getElementById("mySearch").disabled = true;
Click the button to disable the search field.
<!DOCTYPE html> <html> <body> <input type="search" id="mySearch"> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from ww w.j a va 2 s .c o m*/ document.getElementById("mySearch").disabled = true; } </script> </body> </html>
The disabled property sets or gets whether a search field should be disabled, or not.
This property mirrors the HTML disabled attribute.
The disabled property accepts and returns a boolean type value.
Value | Description |
---|---|
true | The search field is disabled |
false | Default. The search field is not disabled |
The disabled property returns true if the search field is disabled, otherwise it returns false.