SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: ReadOnly

  1. #1
    SitePoint Member
    Join Date
    Mar 2002
    Location
    The Netherlands
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question ReadOnly

    Is there a way to make an <input type="text"> readonly through CSS scripting?
    One day I'll understand it.

  2. #2
    SitePoint Addict
    Join Date
    Jul 2001
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think there is a way through CSS, but you could probably enter :
    readonly="readonly"
    into the input tag itself.

  3. #3
    SitePoint Zealot easyrew's Avatar
    Join Date
    Nov 2001
    Location
    Milton Keynes, UK
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think you can do it through CSS either. But you can use the following:

    Code:
    <input name="myName" size="9" readonly>
    Note: no need to assign it a value.

    Rich
    If a man stands alone in the forest
    and there's no woman around to hear him,
    is he still wrong?
    w: www.EasyRew.com

  4. #4
    Posts rarely lloydi's Avatar
    Join Date
    Jan 2002
    Location
    Swindon UK
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Note of warning: the readonly attribute is very poorly supported, even though it would be a very useful one to use.

    We tried using it before, and found that it necessitated unwieldy workarounds for lesser browsers <cough>Netscape 4</cough>. Ended up with to tier approach. Messy
    Build Your Own Web Site the Right Way!
    A beginners' HTML/CSS book with web standards at its heart
    The Ultimate HTML Reference
    A complete reference, in glorious hardback

  5. #5
    SitePoint Member
    Join Date
    Feb 2002
    Location
    Philadelphia
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't know of any good CSS or HTML solution, but you could use Javascript to keep the field from accepting the focus. Just include the following code inside the input tag:

    onFocus="if(this.blur)this.blur()"

    By the way, this does work in NN 4.

  6. #6
    SitePoint Member
    Join Date
    Mar 2002
    Location
    The Netherlands
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Too bad...

    Hope they will study for this propertie in CSS3. But I'm afraid that my hopes are displaced.

    Many thanks for your help !!!
    One day I'll understand it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •