View Full Version : onfocus causing invalid markup??

03-13-2009, 05:43 PM
I am using onfocus in a form to remove the default contents when the user clicks in a field. I'm using this:

onfocus="if (this.value==this.defaultValue) this.value='';"

Although this is working it throws an invalid markup error which says.....

Invalid Markup. Marked invalid because it contains a duplicate attribute.
<input . Remove the duplicate attribute in code view.

Has anyone any idea why this is and how to correct it. Here is the code....

<form action="submit_mail_list.php" method="post">
<input name="submitted" id="submitted" type="hidden" value="1" />
<input name="confirm_link" id="confirm_link" type="hidden" value="http://www.photographybydantucker.com/confirm_mail_list.php?email=" />
<input name="firstname" id="firstname" size="30" class="mail_list" value="First Name" onfocus="if (this.value==this.defaultValue) this.value='';" class="mail_list" />
<input name="lastname" id="lastname" size="30" class="mail_list" value="Last Name" onfocus="if (this.value==this.defaultValue) this.value='';" class="mail_list" />
<input name="email" id="email" size="30" class="mail_list" value="Email" onfocus="if (this.value==this.defaultValue) this.value='';" class="mail_list" />
<div id="submit"><input type="image" name="Go" src="Images/Buttons/submit.gif" alt="Go" title="Go" class="mail_list2" /></div>


03-14-2009, 07:07 AM
Invalid Markup. Marked invalid because it contains a duplicate attribute.

For example, class is an attribute. So if class= appears twice in a tag, it's a duplicate attribute. Simply remove the duplicate.

03-14-2009, 10:50 AM
Thanks Cary,

I looked and looked at those inputs and didnt even notice those classes doubled up. Serves me right for cutting and pasting my code too much lol

Cheers mate.