disabled


To make controls non editable we will use disabled attribute. even readonly will do the same thing but not all the controls have the property readonly.

Syntax:

<select disabled="disabled"></select> <input disabled="disabled" />

Example:

<html> <head> <title>HTML Tutorial</title> <script language="javascript"> function ShowInput() { var input = document.getElementsByName("txtinput"); if (input.length > 0) alert(input[0].value); } </script> </head> <body> Disabled textbox : <input type="text" name="txtinput1" disabled="disabled" /><br /> <br /> Editable textbox <input type="text" name="txtinput2" /><br /> <br /> Disabled dropdown : <select disabled="disabled" id="ddlcountry1"> <option value="Select">Select</option> <option value="India" selected="selected">India</option> <option value="USA">USA</option> <option value="UK">UK</option> </select> Editable dropdown : <select id="ddlcountry2"> <option value="Select">Select</option> <option value="India" selected="selected">India</option> <option value="USA">USA</option> <option value="UK">UK</option> </select> </body> </html>

Output:

HTML Tutorial Disabled textbox :

Editable textbox

Disabled dropdown : Editable dropdown :