Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 08:17 PM
Stan Brown
Guest
 
Posts: n/a
Default INPUT element not allowed in form, can't find my error

http://oakroadsystems.com/nonce/zonk.htm (12 lines)[color=blue]
> http://validator.w3.org/check?charse....htm&outline=x[/color]

The W3C validator says "INPUT is not allowed here". I'm sure my
mistake is really obvious, but I just can't see it. I'd appreciate
another pair of eyes pointing out the problem.

For convenience, here's the entire file. I've stripped it down to
the essentials, still get the message, and still can't see what I'm
missing:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en-US"><head>
<title>How to Convert Units of Measurement</title>
</head>
<body>
<form action="http://www.google.com/search" method="get">
<input type="text" size="40" name="q" value="6145 mi in km">
<input type="submit" value="Google conversion">
</form>
</body>
</html>


--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
  #2  
Old July 20th, 2005, 08:17 PM
Chris Morris
Guest
 
Posts: n/a
Default Re: INPUT element not allowed in form, can't find my error

Stan Brown <the_stan_brown@fastmail.fm> writes:[color=blue]
> The W3C validator says "INPUT is not allowed here". I'm sure my
> mistake is really obvious, but I just can't see it. I'd appreciate
> another pair of eyes pointing out the problem.[/color]

<input> is not allowed directly inside <form> in the strict
doctype. It needs a block level element (<div> or <fieldset> would
seem best) interposed.
[color=blue]
> <form action="http://www.google.com/search" method="get">
> <input type="text" size="40" name="q" value="6145 mi in km">
> <input type="submit" value="Google conversion">
> </form>[/color]

--
Chris
  #3  
Old July 20th, 2005, 08:17 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: INPUT element not allowed in form, can't find my error



Stan Brown wrote:
[color=blue]
> http://oakroadsystems.com/nonce/zonk.htm (12 lines)
>[color=green]
>>http://validator.w3.org/check?charse....htm&outline=x[/color]
>
>
> The W3C validator says "INPUT is not allowed here".[/color]

It says more, it says

document type does not allow element "INPUT" here; missing one of "P",
"H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag

<input type="text" size="40" name="q" value="6145 mi in km">

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


so it tells you you need to wrap the INPUT into a container like P.
If you look at HTML 4 it defines the FORM element as
http://www.w3.org/TR/html4/interact/forms.html#h-17.3
allowing the following content
<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->
where block is defined as
<!ENTITY % block
"P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">

--

Martin Honnen
http://JavaScript.FAQTs.com/

  #4  
Old July 20th, 2005, 08:17 PM
Harlan Messinger
Guest
 
Posts: n/a
Default Re: INPUT element not allowed in form, can't find my error


"Stan Brown" <the_stan_brown@fastmail.fm> wrote in message
news:MPG.1b571f5913a0f03598c6dc@news.odyssey.net.. .[color=blue]
> http://oakroadsystems.com/nonce/zonk.htm (12 lines)[color=green]
> >[/color][/color]
http://validator.w3.org/check?charse....htm&outline=x[color=blue]
>
> The W3C validator says "INPUT is not allowed here". I'm sure my
> mistake is really obvious, but I just can't see it. I'd appreciate
> another pair of eyes pointing out the problem.
>[/color]

Correct. I don't know why, but for strict HTML it was decided that the form
itself wouldn't directly contain its controls, that they should instead be
laid out within the form by placing them within block elements. FIELDSET is
one such block element, so this is a good incentive to use fieldsets to
group your controls on larger forms.

  #5  
Old July 20th, 2005, 08:17 PM
Stan Brown
Guest
 
Posts: n/a
Default Re: INPUT element not allowed in form, can't find my error

"Stan Brown" <the_stan_brown@fastmail.fm> wrote in
comp.infosystems.www.authoring.html:[color=blue]
>http://oakroadsystems.com/nonce/zonk.htm (12 lines)[/color]

(Page now removed)

Thanks to Martin Honnen and Chris Morris for your very prompt
answers, that <form> can't contain <input> but must contain some
extra block-level control which in turn contains <input>.

I had checked the 4.01 spec before posting, but I missed that. And
somehow, even though I looked at the example in 17.4.2, the "<p>"
and "</p>" didn't register on me.

Again, thanks!

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
  #6  
Old July 20th, 2005, 08:17 PM
Neal
Guest
 
Posts: n/a
Default Re: INPUT element not allowed in form, can't find my error

On Thu, 08 Jul 2004 16:18:52 +0200, Martin Honnen <mahotrash@yahoo.de>
wrote:
[color=blue]
> Stan Brown wrote:
> document type does not allow element "INPUT" here; missing one of "P",
> "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag
>
> <input type="text" size="40" name="q" value="6145 mi in km">
>
> 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[/color]

Odd that fieldset isn't mentioned, eh?
  #7  
Old July 20th, 2005, 08:17 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: INPUT element not allowed in form, can't find my error



Neal wrote:[color=blue]
> On Thu, 08 Jul 2004 16:18:52 +0200, Martin Honnen <mahotrash@yahoo.de>
> wrote:
>[color=green]
>> Stan Brown wrote:
>> document type does not allow element "INPUT" here; missing one of "P",
>> "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag
>>
>> <input type="text" size="40" name="q" value="6145 mi in km">
>>
>> 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[/color]
>
>
> Odd that fieldset isn't mentioned, eh?[/color]

Right, the validator should have listed that too.

--

Martin Honnen
http://JavaScript.FAQTs.com/

  #8  
Old July 20th, 2005, 08:17 PM
Jukka K. Korpela
Guest
 
Posts: n/a
Default Re: INPUT element not allowed in form, can't find my error

Martin Honnen <mahotrash@yahoo.de> wrote:
[color=blue][color=green][color=darkred]
>>> document type does not allow element "INPUT" here; missing one of
>>> "P", "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS"
>>> start-tag[/color][/color][/color]
- -[color=blue][color=green]
>> Odd that fieldset isn't mentioned, eh?[/color]
>
> Right, the validator should have listed that too.[/color]

And a few other elements as well. The content model for FORM in the
Strict version is

(%block;|SCRIPT)+ -(FORM)

and %block is defined by

<!ENTITY % block
"P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">

Thus, the "validator" issues an arbitrary sublist of the allowed
elements, in an arbitrary order. I'm using quotation marks here, because
the validator isn't really don't the job of a validator in this
particular issue. A validator must report reportable markup errors; it is
not required to do that in any particular, e.g. optimally understandable,
way. But it's clearly against the spirit to give misleading messages that
strongly suggest that _only_ elements from a particular set would be
allowed. The message given seems to be a fixed string that the
"validator" spits out in certain conditions, even in situations where
you validate against a customized DTD that does _not_ allow the elements
listed in the message as children of FORM!

It's just trying to be helpful in practice. This is how so many
confusions emerge.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

  #9  
Old July 20th, 2005, 08:17 PM
David Dorward
Guest
 
Posts: n/a
Default Re: INPUT element not allowed in form, can't find my error

Jukka K. Korpela wrote:
[color=blue]
> <!ENTITY % block
> "P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
> BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">
>
> Thus, the "validator" issues an arbitrary sublist of the allowed
> elements, in an arbitrary order.[/color]

Not so arbitrary.

It lists them in the order specified in the DTD and lists only those which
may have an <input> as the first child element.

P first, then the %headings (H1, H2, etc), then PRE. DL is skipped as you
would need a DT/DL to contain the input. It shows DIV, but skips NOSCRIPT
(which IIRC has the same content model as <body> and <form> so would need a
block element as the next child), likewise BLOCKQUOTE and FORM are skipped.
HR can't have children at all, TABLE needs TR and TD/TH (and optionally
THEAD/TBODY/TFOOT). FIELDSET has to start with a LEGEND and ADDRESS is
shown.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles