Disable a text field:
document.getElementById("myText").disabled = true;
Click the button to disable the text field.
<!DOCTYPE html> <html> <body> Name: <input type="text" id="myText"> <button onclick="myFunction()">Disable Text field</button> <script> function myFunction() {//from w ww .j a va2 s .c o m document.getElementById("myText").disabled = true; } </script> </body> </html>
The disabled property sets or gets whether a text field is disabled, or not.
Value | Description |
---|---|
true | The text field is disabled |
false | Default. The text field is not disabled |
The disabled property returns true if the text field is disabled, otherwise it returns false.