Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xhtml strict form validation issues 1

Status
Not open for further replies.

jmeyer9807

Programmer
May 18, 2011
4
US
I am currently restructuring a website that utilizes a 3rd party vendor login script (client login portal) on our site. However, I cannot get the script to validate by strict DTD and I am not sure what can be changed without causing usability issues. The invalid errors I am getting are:

there is no attribute "name"
there is no attribute "target"
document type does not allow element "label" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag

And here is the code itself:

Code:
<form name="LoginForm" method="get" action="[URL unfurl="true"]https://app02.3plcentral.com/PresentationTier/LoginForm.aspx"[/URL] target="_blank">
    <label for="tbUsername">User Name</label>
	<input name="tbUsername" id="tbUsername" type="text" />
	<label for="tbPassword">Password</label>
	<input name="tbPassword" id="tbPassword" type="password" />
	<input name="3pl" type="hidden" value="{7c6ac673-0cf2046fc-809a-95dac08b6fb3}" />
	<input type="submit" name="submit" value="Sign In" />
   </form>

If anyone can get me pointed in the right direction on how to validate this as strict, it would be very helpful. I realize this may validate closer under transitional, but my instructions were to have a valid "strict" site. Any suggestions?
 
Ok, slowly making progress. I obviously needed a bit more of an understanding of the "strict" dtd. I moved the div tag "login" inside the "form" tag and instead of 8 errors, I now get 2. The name attribute and target attribute inside form. Any thoughts here?
 
In strict doctypes those doctypes can no loger be used like that.

In strict doctypes only input elements can and should have a name.
Any other element should only have an Id that is unique to it.

Target has been deprecated as there should be no need to open a new window when submitting a form. The only time target can be used is if you are dealing with frames but those too are invalid unless you are using a frameset doctype.

Your last error is pretty self explanatory, labels can't be placed by themselves inside a form, they need to be inside any one of the tags mentioned there.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Correction:
In strict doctypes those doctypes can no loger be used like that.

Should read:

In strict doctypes those attributes can no longer be used like that.
...

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Thank you for your quick response! So I have moved the <div> tag inside of the form tag. Caught that one. Now I will remove the target attribute out as well. My only concern (and understand I know nothing about ASP is if I change the "name" attribute to "id" is that going to cause any issues when clients attempt to login? Again this is a login to a third party website that provides an inventory management system.

Any thought?
 
It shouldn't unless the login processing script is somehow being passed the form's name and needs to do something with it. Which is not commonly the case.
Since I see no JS that would be harvesting the name and sending it over to the ASP script, I assume its not and so it should be safe to remove and either replace with an ID or simply leave out all together.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top