make textbox readonly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manishamca
    New Member
    • Mar 2008
    • 17

    make textbox readonly

    how to make the textbox uneditable when we click a button.
    I want to make the textbox uneditable when we click a button.plz help me.
    thanks in advance.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    hi ...

    refer to your textbox node with getElemenById(' the_textbox_id' ) and set the readonly property to true:

    [CODE=javascript]node_ref.readon ly = true;[/CODE]
    put that in a function and call it onclick of the button.

    kind regards

    Comment

    • vee10
      New Member
      • Oct 2006
      • 141

      #3
      hi,
      [CODE=javascript]document.getEle mentById("Textb oxid").disabled = true;[/CODE]

      or else

      [CODE=javascript]formname.texbox name.disabled = true;
      [/CODE]
      write this code in onclick event of the button

      Originally posted by manishamca
      how to make the textbox uneditable when we click a button.
      I want to make the textbox uneditable when we click a button.plz help me.
      thanks in advance.
      Last edited by gits; Mar 17 '08, 07:48 AM. Reason: remember to use CODE TAGS !!!

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        one note: the text in readonly boxes may be selected and so copied in disabled ones you cannot do that .... but in both cases tha box is not editable :)

        kind regards

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          One other major difference is that disabled field values are not sent when the form is submitted whereas read-only ones are.

          Comment

          Working...