#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    1
    Rep Power
    0

    How to make a non editable text box in HTML


    I want to make a text box as non-editable in an HTML document. But the content of the text should be visible by using the arrow keys, Home key, and End Keys (non editable). Also It should work in both Netscpae Navigator 6+ version and Internet Explorer 6+ version onwards.
  2. #2
  3. a rootin', tootin', shootin'
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Feb 2004
    Location
    location.href="hame"
    Posts
    3,475
    Rep Power
    100
    Code:
    <textarea ... readonly="readonly"> ...
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    7
    Rep Power
    0

    Non editable Text box field in HTML


    Hi,

    Try this code for non editable text box field in HTML.

    <input type="text" name="name" readOnly="true">

    This will work perfectly.

    deven
  6. #4
  7. AYBABTU
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2004
    Location
    Here or There
    Posts
    1,256
    Rep Power
    376
    In both the <textarea> as in in the in the <input type="text"> you should use the readonly attribute like:
    Code:
    <input type="text" value="blah blah" readonly>
    
    <!--or-->
    <textarea readonly>blah blah</textarea>
    Any other form is non standard. See http://www.w3.org/TR/html4/interact/forms.html#h-17.4
  8. #5
  9. a rootin', tootin', shootin'
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Feb 2004
    Location
    location.href="hame"
    Posts
    3,475
    Rep Power
    100
    Originally Posted by wsa1971
    Code:
    <input type="text" value="blah blah" readonly>
    
    <!--or-->
    <textarea readonly>blah blah</textarea>
    if you're using XHTML, you must say readonly="readonly", not just readonly on its own.
  10. #6
  11. AYBABTU
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2004
    Location
    Here or There
    Posts
    1,256
    Rep Power
    376
    Jbot is right, I was wrong. Sorry.

IMN logo majestic logo threadwatch logo seochat tools logo