By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,246 Members | 1,480 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,246 IT Pros & Developers. It's quick & easy.

"input" inside "form" won't validate

P: n/a
Hi folks --

The page at

http://www.pwilson.net/submit-demo.html

will not validate. The validator at http://validator.w3.org tells me I
can't have an input inside a form.

Would some kind soul please tell me what I'm doing wrong?

Thanks!

-- Pete Wilson
Jul 23 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
Previously in comp.infosystems.www.authoring.html, Pete Wilson
<pe**@pwilson.net> said:
Hi folks --
G'day.
http://www.pwilson.net/submit-demo.html

will not validate. The validator at http://validator.w3.org tells me I
can't have an input inside a form.
That's not quite what it is saying. It is saying you can't have an input
element *directly* within a form.
Would some kind soul please tell me what I'm doing wrong?


<form> cannot directly contain inline elements, so the <input> needs to
be inside another block element, such as <fieldset> or <div> (preferably
fieldset).

--
Mark Parnell
http://www.clarkecomputers.com.au
Jul 23 '05 #2

P: n/a
On 23 Nov 2004 14:42:33 -0800, Pete Wilson <pe**@pwilson.net> wrote:
The page at

http://www.pwilson.net/submit-demo.html

will not validate. The validator at http://validator.w3.org tells me I
can't have an input inside a form.

Would some kind soul please tell me what I'm doing wrong?


Strict HTML requires that the children of FORM elements may only be
block-level, or SCRIPT elements. An INPUT is neither. Contain the form
controls in a DIV, or a more meaningful element (if possible).

The BODY element has the same constraint.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3

P: n/a
Pete Wilson wrote:
The page at

http://www.pwilson.net/submit-demo.html

will not validate. The validator at http://validator.w3.org tells me I
can't have an input inside a form.


I think in Strict DTDs, you have to enclose the elements within a form
in a block level container. Try using a fieldset, e.g.

<form action="URL" method="get">
<fieldset>
<input....>
</fieldset>
</form>

--
Chris Simon
os******@slcszetnet.co.uk
http://www.users.zetnet.co.uk/csimon/

** Get rid of all SLCs to reply directly **
Jul 23 '05 #4

P: n/a
Pete Wilson wrote:
will not validate. The validator at http://validator.w3.org tells me I
can't have an input inside a form.

Would some kind soul please tell me what I'm doing wrong?


Forms have the same content model as the <body>. They can have block
elements as children but not inline elements. You need to put a block
element (or elements) (such as a <div>, <fieldset> or <table>) inside the
<form> and your <label>s and <input>s inside that.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #5

P: n/a
"Michael Winter" <M.******@blueyonder.co.invalid> wrote:
On 23 Nov 2004 14:42:33 -0800, Pete Wilson <pe**@pwilson.net> wrote:
The page at

http://www.pwilson.net/submit-demo.html

will not validate. The validator at http://validator.w3.org tells me I
can't have an input inside a form.

Would some kind soul please tell me what I'm doing wrong?
Strict HTML requires that the children of FORM elements may only be
block-level, or SCRIPT elements. An INPUT is neither. Contain the form
controls in a DIV, or a more meaningful element (if possible).


Such as a FIELDSET, a useful way to group controls inside a form, and
to label the groups using the LEGEND element.

The BODY element has the same constraint.

Mike

--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ôter le premier point de mon adresse de courriel.
Jul 23 '05 #6

P: n/a
Chris Simon <os******@sclszetnet.co.uk> wrote:
<form action="URL" method="get">
<fieldset>
<input....>
</fieldset>
</form>


The fieldset element is for grouping related controls and labels, the
above is therefore inappropriate.

--
Spartanicus
Jul 23 '05 #7

P: n/a
Spartanicus wrote:
The fieldset element is for grouping related controls and labels, the
above is therefore inappropriate.


I assumed the provided page was a stripped-down version of a form to
demonstrate the problem, therefore the real page would indeed have
several related controls. The DTD requires that a block level element
should enclose all items within a form therefore you have several to
choose from. Is <p> appropriate? (It's not a paragraph of text). Is
<div> appropriate? (Maybe if it's a separate division of the document).
I would argue that fieldset is probably the most appripriate element to
use. I don't think that this point is really important - I pointed out
that a block level element is required and to try fieldset as an
example, it's up to the author to decide what element he uses.

What element would you use in this case?

--
Chris Simon
os******@slcszetnet.co.uk
http://www.users.zetnet.co.uk/csimon/

** Get rid of all SLCs to reply directly **
Jul 23 '05 #8

P: n/a
Chris Simon <os******@sclszetnet.co.uk> wrote:
The fieldset element is for grouping related controls and labels, the
above is therefore inappropriate.


I assumed the provided page was a stripped-down version of a form to
demonstrate the problem, therefore the real page would indeed have
several related controls. The DTD requires that a block level element
should enclose all items within a form therefore you have several to
choose from. Is <p> appropriate? (It's not a paragraph of text). Is
<div> appropriate? (Maybe if it's a separate division of the document).
I would argue that fieldset is probably the most appripriate element to
use. I don't think that this point is really important - I pointed out
that a block level element is required and to try fieldset as an
example, it's up to the author to decide what element he uses.

What element would you use in this case?


Div, div's are non semantic nor do they signify any structure, so your
assertion that divs should only be used for "divisions" is incorrect.

--
Spartanicus
Jul 23 '05 #9

P: n/a
in comp.infosystems.www.authoring.html, Spartanicus wrote:
Div, div's are non semantic nor do they signify any structure


No, div is devined as grouping element. So it makes no sence to have
<div><img></div>, as you can't group one element.

But using div for that is much better than p for example

http://www.w3.org/TR/html4/struct/global.html#h-7.5.4
| The DIV and SPAN elements, in conjunction with the id and class
| attributes, offer a generic mechanism for adding structure to |
| documents.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Jul 23 '05 #10

P: n/a
Spartanicus wrote:
Div, div's are non semantic nor do they signify any structure, so your
assertion that divs should only be used for "divisions" is incorrect.


Would you care to offer any practical advice instead of a robotic "your
statement is incorrect"? *I* think your statements are incorrect.

--
Chris Simon
os******@slcszetnet.co.uk
http://www.users.zetnet.co.uk/csimon/

** Get rid of all SLCs to reply directly **
Jul 23 '05 #11

P: n/a
Chris Simon <os******@sclszetnet.co.uk> wrote:
Div, div's are non semantic nor do they signify any structure, so your
assertion that divs should only be used for "divisions" is incorrect.
Would you care to offer any practical advice instead of a robotic "your
statement is incorrect"?


You asked what element I would use, I answered "div", how's that not
"practical"?
*I* think your statements are incorrect.


Fine, I don't care. If you want to start a discussion then you have to
do better. Provide an argument as to why you think I'm incorrect.

--
Spartanicus
Jul 23 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.