Ways of setting Readonly to true or false through Javascript.

vishalneeraj-24503
Posted by vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 629
1st way:-
document.getElementById("txt_description").readonly = true;

2nd way:-
document.forms[0].txt_description.setAttribute('readonly','readonly');


3rd way:-
document.forms['form1'].txt_description.setAttribute('readonly','readonly');


4th way:-
document.forms['form1'].txt_description.readonly = true;


//txt_description is defined in aspx page as:
<asp:TextBox ID="txt_description" runat="server" TextMode="MultiLine"></asp:TextBox> 

Comments or Responses

Login to post response