Jump to content

Form won't validate


VaporAction

Recommended Posts

My search field won't validate (as HTML 4.01 strict) and I can't figure out why...here's the code...

<div>	<form action="http://www.google.com/search" method="get" onsubmit="search(this)">		<input name="q" type="hidden">		<input id="searchField" name="qfront" type="text"> <input type="submit" value="Search">	</form></div>

Link to comment
Share on other sites

If you post by the error message you get, it'll be a lot easier. But I think you need to use name="" instead of id="" - I'm not sure.I only use name="" and that validates with XHTML 1.0 transitional, strict and XHTML 1.1 (not tried the others)

Link to comment
Share on other sites

If you post by the error message you get, it'll be a lot easier. But I think you need to use name="" instead of id="" - I'm not sure.I only use name="" and that validates with XHTML 1.0 transitional, strict and XHTML 1.1 (not tried the others)
I used id so I could call it in CSS...anyway, here's the error message...# Error Line 30 column 32: document type does not allow element "INPUT" here; missing one of "P", "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag. <input name="q" type="hidden">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>").✉# Error Line 31 column 52: document type does not allow element "INPUT" here; missing one of "P", "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag. <input id="searchField" name="qfront" type="text"> <input type="submit" value="Search">✉# Error Line 31 column 89: 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="submit" value="Search">✉# Error Line 32 column 8: end tag for "FORM" which is not finished. </form>Most likely, You nested tags and closed them in the wrong order. For example <p><em>...</p> is not acceptable, as <em> must be closed before <p>. Acceptable nesting is: <p><em>...</em></p>Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is "not finished", not complete. For instance, <head> generally requires a <title>, lists (ul, ol, dl) require list items (li, or dt, dd), and so on.
Link to comment
Share on other sites

Oh no! You have that error! Sometimes I have it too, and still I haven't figured out I can validate my site then. Because I put <p><input type="text" name="sf" /></p> but still it doesn't validate. (I put it around all inputs btw)

Link to comment
Share on other sites

I was just testing some things about your code. I put this code in the HTML validator and it validated no problem. So I'm guessing it's not the form but something before it. Wanna paste your complete page code?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Untitled Document</title></head><body><div>    <form action="http://www.google.com/search" method="get" onsubmit="search(this)">        <input name="q" type="hidden">        <input id="searchField" name="qfront" type="text"> <input type="submit" value="Search">    </form></div></body></html>

Link to comment
Share on other sites

are you pasting your code into the validator or are you entering the URL to the page?I kicked my self in the arse all night one time with this same problem. I had forgotten that I had debugging turned on and that extra information in the footer killed my validation.(just a thought)

Link to comment
Share on other sites

are you pasting your code into the validator or are you entering the URL to the page?I kicked my self in the arse all night one time with this same problem. I had forgotten that I had debugging turned on and that extra information in the footer killed my validation.(just a thought)
HA! I did that once with one of my sites!I checked everything except that!
Link to comment
Share on other sites

I tried it both by entering the URL and by entering the code...won't validate...also, remember it's HTML Strict, not Transitional...here's the full page...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"		"http://www.w3.org/TR/html4/strict.dtd"><html lang="en"><head>	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">	<title>Wired Chemist</title>	<meta name="keywords" content="wired chemist, chemistry, mineralogy, environmental, nmr, spectroscopy, science, education, tutorial, flash, animation">	<meta name="description" content="The Wired Chemist is an online collection of scientific resources, including databases, tutorials and animations.">	<link rel="stylesheet" href="css/global.css">	<script type="text/javascript" src="scripts/tierOne.js"></script></head><body><div id="wrapper">	<div id="header">		<a id="logo" href="index.html"><img src="images/logo.gif" width="107" height="25" alt="Wired Chemist"></a>		<div id="nav">			<a href="chemistry/chemistry.html" onMouseOver="chemOver()" onMouseOut="chemOut()"><img id="chem" src="images/btnChem.gif" width="125" height="36" alt="Chemistry"></a><a href="mineralogy/mineralogy.html" onMouseOver="minOver()" onMouseOut="minOut()"><img id="min" src="images/btnMin.gif" width="135" height="36" alt="Mineralogy"></a><a href="environmental/environmental.html" onMouseOver="envOver()" onMouseOut="envOut()"><img id="env" src="images/btnEnv.gif" width="160" height="36" alt="Environmental"></a><a href="nmr/nmr.html" onMouseOver="nmrOver()" onMouseOut="nmrOut()"><img id="nmr" src="images/btnNMR.gif" width="90" height="36" alt="NMR"></a>		</div>		<img id="logo-chem" src="images/logo-chem.gif" width="107" height="25" alt="Chemistry">	</div>	<div id="stageText">		<p class="textWelcome">Welcome to the Wired Chemist!		</p>		<p class="content">The site has four main divisions. They are <a href="chemistry/chemistry.html">Chemistry</a>, <a href="mineralogy/mineralogy.html">Mineralogy</a>, <a href="environmental/environmental.html">Environmental</a> and <a href="nmr/nmr.html">NMR</a>. The four divisions are further broken into three sections. An instructional section which covers course materials such as lecture notes and laboratory directions as well as animations that demonstrate various scientific principles. A data tables section displays a variety of information related to that discipline. The last section is a listing of numerous links for both the student and professional scientist.		</p>	</div>	<div id="footer">		<p>Copyright © 2007 <a href="http://server1.fandm.edu/departments/chemistry/Links%20gifs%20/FacultyStaff%20gifs/claudeyoder.htm">Claude Yoder</a>. All rights reserved.<br>		Site design by <a href="http://www.karlyoder.com/">Karl Yoder</a></p>		<form action="http://www.google.com/search" method="get" onSubmit="search(this)">			<input name="q" type="hidden">			<input id="searchField" name="qfront" type="text"> <input type="submit" value="Search">		</form>	</div></div></body></html>

Link to comment
Share on other sites

<input> is not allowed directly inside <form> in the strictdoctype. It needs a block level element (<div> or <fieldset> wouldseem best) interposed.
I tested with <div> inside the form element and it validates.
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...