Javascript examples for DOM HTML Element:Input Text
The disabled property sets or gets whether a text field is disabled.
Set the disabled property with the following Values
Value | Description |
---|---|
true|false | Sets whether a text field should be disabled |
A Boolean, returns true if the text field is disabled, otherwise it returns false
The following code shows how to disable a text field:
<!DOCTYPE html> <html> <body> Name: <input type="text" id="myText"> <button onclick="myFunction()">Disable Text field</button> <script> function myFunction() {/*w w w . j av a 2 s. com*/ document.getElementById("myText").disabled = true; } </script> </body> </html>