Results 1 to 7 of 7

Thread: the disabled attribute in XHTML [resolved]

  1. #1

    Thread Starter
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090

    the disabled attribute in XHTML [resolved]

    I've used JS to change the disabled attribute quite a bit. I use disabled="disabled" to disable something and disabled="" to enable it. I found that MSDN says you should use true/false, but then this page on the W3C says you should use what I use for dissabling them. I tried setting disabled="" and disabled="false" and disabled="enabled". None of these were allowed by XHTML1.0 Strict or transitional. What's the right way of doing this? I realise that you can simple leave out the attribute, but when changing it wil JS what should you set it to?
    Last edited by Acidic; Sep 2nd, 2004 at 04:06 PM.
    Have I helped you? Please Rate my posts.

  2. #2
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Well... I'd say if you're expecting it to work in IE, better go by what MSDN says. Now... if you want to do it the RIGHT way... then do what the standard says.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  3. #3
    Fanatic Member riis's Avatar
    Join Date
    Nov 2001
    Posts
    551
    Omit the disabled attribute entirely if you don't want to have the textbox disabled. Delete the attribute with JavaScript (removeAttribute).

    In "old" HTML you only had to type "disabled" if you wanted to disable a form control. I've understood that for XHTML all those single-worded statements should be expanded to ' statement="statement" ', and if it doesn't occur, then just leave it out.

  4. #4
    Fanatic Member riis's Avatar
    Join Date
    Nov 2001
    Posts
    551
    If this doesn't work for IE, I'm afraid you need to include some object detection to determine in which browser your code is running...

  5. #5

    Thread Starter
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    sorry for not clearing up. both the old style, the true/false method and "disabled"/"" work in all browsers I've tried. I was just looking for how to do it following the standards, thanks for the reminder on removeAttribute, I had totally forgotten about that one as I have never actully used it. That would be the way to go.
    Have I helped you? Please Rate my posts.

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    The XHTML attribute disabled should be set to "disabled" to disable and to "" (or removed) to enable.
    The JavaScript property disabled should be set to true or false.
    If you use setAttribute in JavaScript, use the values for the attribute.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    Originally posted by CornedBee
    The XHTML attribute disabled should be set to "disabled" to disable and to "" (or removed) to enable.
    If you leave it blank, then it's not valid. Otherwise thanks a lot for that.
    Have I helped you? Please Rate my posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width