What's the proper structure for forms?

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

This is my code:

<form action="search.php" method="post" id="search">
<input type="hidden" name="forumchoice" value="- 1" />
<input type="hidden" name="searchin" value="subject" />
<input type="hidden" name="searchdate" value="-1" />
<input type="hidden" name="action" value="simplesearch" />
<input type="hidden" name="booleanand" value="yes" />
<input type="hidden" name="s" value="$session[sessionhash]" />
<input class="searchinput" onFocus="this.value='';"
     onBlur="if (this.value=='') {this.value='Search for...';}"
     type="text" name="query" value="Search for..." size="14" />
<input type="image" src="$stylevar[imgdir_misc]/navgraphics/go.gif"
     alt="$vbphrase[search]" />
</form>
'I'm getting a validation error under xhtml 1.0 strict that "document type does not allow element "input" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag.". So how am I supposed to structure this?

timjpriebe's picture

He has: 2,667 posts

Joined: Dec 2004

I believe they just need to be enclosed in a tag for it to validate. The form needs to be a part of something, instead of just hanging out there. In this case, a paragraph would probably work best.

But hey, who cares about validation? Wink

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

I tried to enclose the whole thing in a p and it didn't work (if I remember right...). Does it need to be inside the form tags, is that it???

And I care about validation! Laughing out loud

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

What about the tag?

demonhale's picture

He has: 3,278 posts

Joined: May 2005

and you already have a form tag...

Roo's picture

She has: 840 posts

Joined: Apr 1999

Perhaps because your onblur and onfocus contains uppercase charecters?

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

Oh yeah, didn't see those. That'll be it. They need to be lower case...

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

So that would be causing the nesting error???? I need to take those out anyway but the functionality needs to be built elsewhere. Will try that and see but I'm rather skeptical. OnFocus and OnBLur are throwing erorrs themselves (but I know how to solve that one! Jeeves!).

Roo's picture

She has: 840 posts

Joined: Apr 1999

I once drove myself nuts trying to get a bit of script to validate. It had some uppercase chaerters like that. I spent three days going crazy, because the validator will not retrun an error that tells specfically that when something is written likeThis that you need all lowercase. I wish it would. I've seen something so simple like that throw an entire page into errors. I finally figured it out myself, but was right on the edge of insanity before I did.

Roo

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.