Jump to content

XHTML will not validate


feck

Recommended Posts

Hello everyone,I'm new to this so please be gentle, I'm having trouble validating this piece of code.Basically the validator tell me that the document type does not allow labels or inputs where I've placed themalso that the end tag for the form is not finished.

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb"><head><title>Test1</title><link rel="stylesheet" href="test.css" style="text/css" /></head><body><div id="wrap">	<div id="masthead"><h1>sillywebsite</h1></div>	<div id="leftnav"><h4>Welcome</h4>		<div id="buttonsContainer">			<div class="buttons">				<a href="index.html">Home</a>				<a href="search.html">Search</a>				<a href="test.html">test</a>			</div>		</div>	</div>	<div id="main"><h2>Please Sign In:</h2>		<form action="">			<label>Staff ID:<input type="text" name="staffID" size="10" maxlength="8"></input></label>			<label>Password:<input type="password" name="password" size="10" maxlength="8"></input></label>			<input type="submit" value="Submit" name="submit1" onclick="return Validate(this.form)"></input>			<input type="reset" value="Reset Form"></input>		</form>	</div>	<div id="footer"><h2>Footer Area</h2></div></div></body></html>

Please help as this is bending my brain trying to figure out why it will not validate.Thankyou

Link to comment
Share on other sites

As far as I know that isnt correct.

<form action="">

try to change it for that :

<form  method="post" action=" ">

Also, the correct way to use input is <input />the correct code would be :

<div id="main"><h2>Please Sign In:</h2>		<form action="">			<label>Staff ID:<input type="text" name="staffID" size="10" maxlength="8"/></label>			<label>Password:<input type="password" name="password" size="10" maxlength="8"/></label>			<input type="submit" value="Submit" name="submit1" onclick="return Validate(this.form)"/>			<input type="reset" value="Reset Form"/>		</form>	</div>

Link to comment
Share on other sites

Thanks for trying tarte.But thats how I originally had my code, and just changed it to this to see if it would work.Still comes up with the same 5 errors.The form attribute 'action' validates as its the only required attribute for form all the others are optional.any other suggestions?

Link to comment
Share on other sites

Success Fixed it.God the wonders of googling, just found out that if you place the inputs inside a div they will validate.Why I dont know, could be a quirk in the validator perhaps when working with XHTML 1.1?Would anyone know.Anyway if anyone has a similar problem then theres your answer.Thanks anyway tarte again for trying. :)

Link to comment
Share on other sites

Try a set of <p></p> tags. The label and input tags need to be in some sort of a containing block.And you still need an action="filename.ext" and a method=("post" or "get") or else the form won't go anywhere or have any data once you get there.

Link to comment
Share on other sites

Success Fixed it.God the wonders of googling, just found out that if you place the inputs inside a div they will validate.Why I dont know, could be a quirk in the validator perhaps when working with XHTML 1.1?Would anyone know.
The reason is input is NOT valid child element of form in XHTML 1.1But input IS valid child element of div.Check valid child elements of form element:http://learningforlife.fsu.edu/webmaster/r.../forms/form.cfmNo input there.And then check valid child elements of div element:http://learningforlife.fsu.edu/webmaster/r...gs/text/div.cfmYes, there is input.
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...