Read only Textbox

In jQuery how do you make a textbox read only and how do you turn it back.

This is what I tried:

$("#<%= TextBox1.ClientID %>").readonly();

Hi there,

You set the readonly attribute to true to make the input field read only.
You can use removeAttr to remove it, or set it to false.

Here’s a small example:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Read only textbox example</title>
    <script src="" type="text/javascript"></script>
      <input type="text" id="myTextBox" value="Well, hello there!" />
    <button id="myButton">Make read-only</button>
    $(document).ready(function() {
      var t = $("#myTextBox");
      var b = $("#myButton");
      b.on("click", function(){
        if (t.attr('readonly')){
          b.text("Make read-only");
        } else {
          t.attr('readonly', true);
          b.text("Remove read-only");

Thanx exactly what i needed.