homepage Welcome to WebmasterWorld Guest from 54.205.193.39
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
One Validation Error Left
Sprink




msg:4279377
 4:50 am on Mar 10, 2011 (gmt 0)

Let it be said first and foremost that I always have the biggest problems with forms. ^_^

I am one error away from finishing validation on a website I'm putting together. However, I just can't seem to wrap my mind around how to fix it. Any help would be greatly appreciated!

DOCTYPE is PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN

The code in question is:

<div id="right_side">

...

<p>
<form name="contact_us" id="contact_us" method="post" class="form.contact_us" action="mailto:example@example.com">
<p><label>Name
<input type="text" class="input.fields_contact_us" name="name" tabindex="1"/>
</label>
<label>E-mail
<input type="text" class="input.fields_contact_us" name="email" tabindex="2"/>
</label>
<label> Your message:
<textarea name="message" class="textarea" rows="" cols="" tabindex="3"></textarea>
</label>
<label>
<input type="submit" class="submit_button_contact" name="Submit3" value="Submit" />
</label></p>
</form>
</p>

</div>

Thank you all in advance! ^_^

 

tangor




msg:4279388
 5:28 am on Mar 10, 2011 (gmt 0)

I see, immediately, an open <p> without a close... Might want to check all those... count 'em up...

Sprink




msg:4279399
 5:50 am on Mar 10, 2011 (gmt 0)

I see two open <p> 's and two closed </p> 's...

Unless, they're in the wrong spots. I don't think so, but I could be wrong.

Fotiman




msg:4279582
 1:55 pm on Mar 10, 2011 (gmt 0)

What is the validation error?

topr8




msg:4279585
 1:58 pm on Mar 10, 2011 (gmt 0)

>>I see two open <p> 's and two closed </p> 's...

it's invalid to have a <p> inside another <p>

but also as Fotiman says, what's the error message?! it would be helpful

Sprink




msg:4280209
 3:21 pm on Mar 11, 2011 (gmt 0)

The message I'm getting is as follows:

document type does not allow element "form" here; missing one of "object", "applet", "map", "iframe", "ins", "del" start-tag

t_us" method="post" class="form.contact_us" action="mailto:example@example.com">

The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

Fotiman




msg:4280219
 3:34 pm on Mar 11, 2011 (gmt 0)

A <p> element can not contain a form. A <p> element can contain only inline elements. The <form> element is a block element. Remove the <p> around your form and try again.

rocknbil




msg:4280284
 5:08 pm on Mar 11, 2011 (gmt 0)

You can drop to a 4.01 doctype or html 5 if you're not using anything *requiring* XHTML.

While you're at it, here is a "proper" application of label as well. I don't know why I see so many instances of this usage - label around the label and field - but anyway . . .

<p><label for="your-name">Name</label>
<input type="text" class="input.fields_contact_us" name="name" id="your-name" tabindex="1"/>
</p>

Note also with XHTML doctypes, hidden fields will error, they need a container (though you're not using it here: )

<div><input type="hidden" name="blah" id="blah" value="blah"/></div>

Fotiman




msg:4280307
 5:50 pm on Mar 11, 2011 (gmt 0)

rocknbil, both usage cases are "proper".

[w3.org...]

for = idref [CS]
This attribute explicitly associates the label being defined with another control. When present, the value of this attribute must be the same as the value of the id attribute of some other control in the same document. When absent, the label being defined is associated with the element's contents.



I don't know why I see so many instances of this usage - label around the label and field

I've seen it done this way for CSS purposes. I forget the exact use case though. It is more compact as well.

SuzyUK




msg:4280474
 11:25 pm on Mar 11, 2011 (gmt 0)

both use cases are indeed proper, and I know the reasons ;) - using the label as a "wrapper" does not affect it's focus abilities (i.e. clicking the label still puts the cursor in the input box) but it does allow you to align the input to the label (container) right side or use it's overflow property to simulate columns.. not sure if that's right or wrong, but it has always validated and has always been the best way to use existing elements rather than adding an unnecessary wrapper.. I welcome the chance to be corrected if there's a newer reason not to do it this way any more

however that doesn't answer the OP, @tangor it's quite legitimate to not have a closing </p>.. browsers will auto close them.. like many other elements actually, it's only when you use and XHTML Doctype that you will learn this and then if you decide to use a transitional or HTML Doctype you no longer need to be pedantic about closing tags but you still need to know when not to close them ;)

so back to the OP: that very first <p> is closed, implicitly, by the browsers before the opening <form>, therefore making the very last closing </p> invalid.. it's not closing anything,

the one in the middle surrounding the labels and inputs is valid but quite why you would need it I'm not sure.. is a form a paragraph? - if it's styling then padding and margins (spacing) could be applied to the <form> itself

tangor




msg:4280510
 1:39 am on Mar 12, 2011 (gmt 0)

@suzyUK, only mentioned the <p> irregularities because of the OP's xhtml doc type... which wants all tags closed... Otherwise, agree with all you observed.

SuzyUK




msg:4280520
 2:27 am on Mar 12, 2011 (gmt 0)

thanks, but I just thought the
count 'em up...
statement doesn't work for any Doctype - browsers will close them anyway and I thought that to be a very misleading reply to anyone looking for a validation error, errors like that don't usually affect display due to a browsers inbuilt error recovery - they will only show up via the validator..as long as you weren't actually trying to style that <p> you're good to go ;)
tangor




msg:4280623
 8:57 am on Mar 12, 2011 (gmt 0)

The "count 'em up" still holds true... a </p> without an opening is gonna tank! :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved