title: Setting textbox to readonly not working in Javascript
body: <p>I have tried the following codes to set a textbox property to readonly but none of them is working. Can anyone tell me how to do it?</p>
  
  <pre><code>document.getElementById("phone_numbers").disabled=true;
  document.getElementById("phone_numbers").readonly=true;
  document.getElementById("phone_numbers").readOnly=true;
  document.getElementById("phone_numbers").readOnly=readOnly;
  document.getElementById("phone_numbers").readOnly=readonly;
  document.getElementById("phone_numbers").readonly=readonly;
  document.getElementById("phone_numbers").readonly=readOnly;
  document.getElementById("phone_numbers").setAttribute('readonly', 'readonly');
  document.getElementById("phone_numbers").setAttribute("readonly", "true");
  </code></pre>
  
  <p><strong>EDIT</strong><br>
  While I was editing my question to write more detail I realized what the problem was. I made a silly mistake. This was my original HTML code.  </p>
  
  <pre><code>&lt;input name="phone_numbers"&gt;
  </code></pre>
  
  <p>And I changed it to</p>
  
  <pre><code>&lt;input id="phone_numbers"&gt;
  </code></pre>
  
  <p>And it worked!</p>
  
  <p>By the way following are the functions that are actually working.</p>
  
  <pre><code>document.getElementById("phone_numbers").disabled=true;
  document.getElementById("phone_numbers").readOnly=true;
  document.getElementById("phone_numbers").setAttribute('readonly', 'readonly');
  document.getElementById("phone_numbers").setAttribute("readonly", "true");
  </code></pre>