Forum Moderators: open

Message Too Old, No Replies

Input element - no onClick in XHTML

XHTML validation error on Forms

         

Victoria_B

9:56 pm on Dec 27, 2003 (gmt 0)

10+ Year Member



*Sorry* folks but I'm a little new to XHTML and so ran one of my pages through the W3C's XHTML validator and it marked the following code -

<input name="enable" type="button" value="Enable" onClick="javascript: accessEnable()" />

as "Line 128, column 111: there is no attribute 'onClick' "

Err?... So how do I make the above HTML code XHTML compliant when the "onClick" attribute is considered depricated?

Victoria - Stumped... :(

tedster

10:23 pm on Dec 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, Victoria_B.

XHTML requires all lower case letters for attributes. So the long-standing convention of capitalizing the event type in an event handler now bites the dust in XHTML. Try "onclick" and the line should validate.

Victoria_B

10:55 pm on Dec 27, 2003 (gmt 0)

10+ Year Member



Simple problem = simple answer.

(Even though I'd already successfully transfered about 30 pages over to XHTML - I guess after a long day I just couldn't see the woods for the trees)

Thanks Tedster - you're a star!

Victoria x

choster

5:57 pm on Dec 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Incidentally, the javascript: is generally superfluous. You can usually just say

<input name="enable" type="button" value="Enable" onClick="accessEnable()" />