Jump to content

validator doesn't like my form SOLVED with thanks in our last post


niche

Recommended Posts

I'm trying to move this site from transitional to a strict doctype and it doesn't like this form (at least it didn't throw an error until I added the form). What should I be understanding?

echo '<form  action="see_cart.php" method="post">';	 echo '<input   type="hidden" name="user" value="' . $fn_upper . '" >';	 echo '<input type="submit" class="cart" value="See Cart"  >';echo '</form>';

I get three errors: Line 249, Column 564: document type does not allow element "INPUT" here; missing one of "P", "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag Line 249, Column 617: document type does not allow element "INPUT" here; missing one of "P", "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag Line 249, Column 624: end tag for "FORM" which is not finished here's the link: http://www.lincolnsr...111_debuger.php

Edited by niche
  • Like 1
Link to comment
Share on other sites

you should close the input tags

Link to comment
Share on other sites

<input> elements or other inline elements cannot be placed directly inside a form, you need a block element to surround them. That's why you're getting a validation error. If your document is HTML, you don't need to close the <input> tags.

  • Like 1
Link to comment
Share on other sites

That worked Ingolme. Thank you very much. I know you can't know, but how could I not know that??? I've never wrapped inputs in a <p> before. Is there a ref for that in w3schools you're aware of? If not, is there another ref you can think of? This is a pretty basic omission. It would be nice to get some idea how I missed that. Maybe it's just the "strict" that forced the issue for me finally.

Link to comment
Share on other sites

Guest So Called

I wondered that too. Truth be told I spent 20-25 minutes on your form problem just because I was curious if I could solve it. I compared your form to my contact form and didn't see why mine works and yours didn't. After reading Ingol's reply I realized that I too put my <INPUT> elements inside <P> elements. I read and re-read the W3S docco on <FORM> and never saw any indication that <INPUT> needed a block. If the <INPUT> docco says to use a block around it I never saw that. <FORM> is a block element and you'd think that would be enough.

  • Like 1
Link to comment
Share on other sites

Must be some strict thing. That's one requirement I won't soon forget. Thanks for all your help birbal, Ingolme, and So Called. It's time to call it a day.

Link to comment
Share on other sites

hhhhmmmmaaaa inputs are not/or don't act as totally inline, more like inline-block, with input elements you can define width/height, true inline width/height depends on content within it .if you look up inputs under http://www.w3.org/ they are listed as form controls, but can't find any reason why they should NOT be allowed without being surrounded by block element, other-than well they say they should be. Yet! another stupid Strict doctype rule, No iframes, now no inputs within form unless surrounded by black element .

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...