SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2008
    Location
    South Florida
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Event Handlers and Passing XHTML Validation

    I've been looking around but can't seem to find a solution for this...
    How do you attach event handlers to elements (onFocus, OnClick, etc.) without breaking XHTML Validation.
    I have my doctype as XHTML 1.0 Transitional.

    Any ideas?

  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    xhtml is case sensitive. If you're attaching handlers inline then they need to be onfocus, onclick, etc.

  3. #3
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Also, Transitional doctypes are terrible and should not be used.

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So are inline event handlers. Scripts should be external and unobtrusive.
    Birnam wood is come to Dunsinane

  5. #5
    Non-Member
    Join Date
    Jul 2005
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, Transitional doctypes are terrible and should not be used.
    Unless you are living in the real world?

  6. #6
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Of course. In the fictional world, we choose to limit ourselves to the unreasonable.

  7. #7
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Bob Carologees View Post
    Unless you are living in the real world?
    I've never had any need to use a Transitional doctype, so I guess I'm not living in the real world then.
    Birnam wood is come to Dunsinane

  8. #8
    SitePoint Evangelist
    Join Date
    Apr 2008
    Location
    Dublin, Ireland
    Posts
    461
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mastermindxs - have a read of this -

    http://onlinetools.org/articles/unobtrusivejavascript/

    Might be of some help.

  9. #9
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The transitional doctype is for updating old web pages where it is not yet practical to completely rewrite the page to the current standards.

    Pages that are completely new should always use a strict doctype.

    There are so many ways of handling JavaScript unobtrusively that using JavaScript embedded in the HTML is never required. Of course if someone who doesn't know JavaScript is just plugging an old pre-written script into their page they are not going to be able to fix the script to work unobtrusively and will have to go with inline code.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  10. #10
    SitePoint Enthusiast
    Join Date
    May 2008
    Location
    South Florida
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    great thanks man, i didnt realize that all it took was to lowercase the eventhandlers, and i passed Strict Validation! WOO!

  11. #11
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It still means you're still using inline event handlers which, if you'd bothered to read felgall's post above, you shouldn't be so thrilled about.


Tags for this Thread

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
  •