How to set textbox to readonly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gsreenathreddy
    New Member
    • Oct 2007
    • 40

    How to set textbox to readonly

    hi!

    I am using a datepicker from javascript i would like to store only the date from the datepicker into the textbox. Can any one suggest me how to use it. Please do not say go google i had gone through it but i am unable to find it.

    Thank you,
  • VijaySofist
    New Member
    • Jun 2007
    • 107

    #2
    Hi!

    If you not want directly to edit into the Text Box Try the following bolded words in the code given below

    <input type=text value="Vijay" id="txt1" contenteditable =false />

    All the Best

    With Regards
    Vijay. R

    Comment

    • drhowarddrfine
      Recognized Expert Expert
      • Sep 2006
      • 7434

      #3
      There is no such thing as "contenteditabl e".

      This is a javascript question so I'm moving it there.

      Comment

      • Dasty
        Recognized Expert New Member
        • Nov 2007
        • 101

        #4
        Code:
        <input type=text value="Vijay" id="txt1" readonly  />
        in html

        OR
        [CODE=javascript]document.getEle mentById('txt1' ).setAttribute( 'readonly','tru e');[/CODE]
        in javascript

        Comment

        • Romulo NF
          New Member
          • Nov 2006
          • 54

          #5
          Actually you should use

          <input type="text" readonly="reado nly">

          Or using js you can

          Code:
          <input type="text" onclick=" if (!this.readOnly) { this.readOnly = 'readOnly' } else { this.readOnly = '' } ">

          Comment

          Working...