Using comments to create unobtrusive JS?

"Derksen, Ron" <[email protected]> Tue, 21 Mar 2006 13:27:27 +0100
Newsgroups gmane.comp.web.dom.wdf
Message-ID <[email protected]>
Hi,

I recently came across a form validation script that used HTML comments to
define the parameters for the JS validation. The javascript code then walks
through the form searching for the fields, and looks up the associated
comments (association is done by placing the comments right after the field
HTML).

Of course, the advantage of this approach is that it there are no event
handlers defined in the HTML code (so no onclick, onblur, onwhatever) and a
clean(er) separation of presentation and business logic in the frontend.

As I find this approach quite charming, I was wondering if anyone else is
using this, and if anyone sees a problem with using this technique. The
javascript itself uses fully validating DOM scripting to find the comment
nodes, so there should be no problem in using it.

So, what do you think?

Ron Derksen


Unsubscribe
[email protected]

List info
http://www.quirksmode.org/dom/list.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wdf-dom/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/