Disable and enable a text field:
<!DOCTYPE html> <html> <body> First Name: <input type="text" id="myText" value="Mickey"><br> <button onclick="disableTxt()">Disable Text field</button> <button onclick="enableTxt()">enable Text field</button> <script> function disableTxt() {/*from ww w . j av a 2 s.c o m*/ document.getElementById("myText").disabled = true; } function enableTxt() { document.getElementById("myText").disabled = false; } </script> </body> </html>