Jump to content

W3C validation fails


CanadianGuy

Recommended Posts

Hi everyone,Well I'm bummed. I was validating a website and everything was going just great until I got to my contact form and then things went horibly wrong, 51 errors. I'm using a script that I found from TecTile. I believe they have a very strong script with spam protection, error checking and I'm able to use templates and even my email address is not in the form but rather uses an ini file. So lots of great stuff but gees 51 errors.Here just one example from W3C.<form method="post" action="http://www.domainname.com/formmail/formmail.php" name="GeneralContact">

You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead). This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information. How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute.
I can reduce the number of errors to 41 by using Transitional doc type but I'm really going for Strict.So my real problem here is I don't even know where to begin. I know if I fix many of these errors the mail script will fail and or send some very unatractive emails. For example no subject or no reply email, that sort of thing. This script was very difficult for me to set up and I hope not to have to start all over with a new one.I am looking for your advice, suggestions, thoughts and whatever else you got for me.Thanks so much,Jeff
Link to comment
Share on other sites

Well for the example you posted, it's referring to the name attribute of the form, which is deprecated. Your script has JavaScript I presume? Does it use dot notation to get a reference to the form? (document.GeneralContact) If that is the case, change the name to an id and get your reference like this:document.getElementById("GeneralContact")As for other errors, I can't say without seeing them, but fixing them is likely going to involve some rework with your script.

Link to comment
Share on other sites

Well for the example you posted, it's referring to the name attribute of the form, which is deprecated. Your script has JavaScript I presume? Does it use dot notation to get a reference to the form? (document.GeneralContact) If that is the case, change the name to an id and get your reference like this:document.getElementById("GeneralContact")As for other errors, I can't say without seeing them, but fixing them is likely going to involve some rework with your script.
Actually, absolutely no JavaSript on my site. Script is PHP and a little over 12,000 lines long. Reworking it would be out of my means and I think possibly illegal as it is commercial software. My form simply sends the emails to thier script that process it. So the problem is with my form but I did follow thier suggested guidelines but I guess it didn't work out so well for me.As I am using the free version of thier script I am not entitled to tech-support. I'll be burning my eyes out I'm sure looking over my form to see what I can fix and can not fix. But should I just pack it in and start over again? I sure hope not.
Link to comment
Share on other sites

If it's all php you may be in luck. Unless it's the php that's creating the form. Is your HTML generated by the PHP script? Or did you write the HTML part?
LOL... nope I'm the problem, as much as I'd like to blame the script I can't. The HTML is all my doing. But using their instructions.For example the script will not process without a name being applied to it as my example name="GeneralContact" suggests. This one line tells the script which email list to use in the ini file that the script uses. I can give the name any description I like but W3C doesn't like the "name" field.The ini file is a simple text file and W3C never sees it or the PHP file.
Link to comment
Share on other sites

LOL... nope I'm the problem, as much as I'd like to blame the script I can't. The HTML is all my doing. But using their instructions.For example the script will not process without a name being applied to it as my example name="GeneralContact" suggests. This one line tells the script which email list to use in the ini file that the script uses. I can give the name any description I like but W3C doesn't like the "name" field.The ini file is a simple text file and W3C never sees it or the PHP file.
So did you modify the ini file to use the name? I'm not sure that PHP would be able to retrieve the name of the form.
Link to comment
Share on other sites

So did you modify the ini file to use the name? I'm not sure that PHP would be able to retrieve the name of the form.
Yes, the end user (me) creates the ini file. It's just a list of email addresses to use for a given form so that you can have multiple forms that get mailed to different email addresses. My form does not process the ini file.eg ini file...GeneralContact="email1,email2,email3"HeadOffice="email4,email5"etcetray.So my form passes GenerContact to the php script which retrieves the list of email address, in this case 3 of them, and sends the filled form to all three addresses.
Link to comment
Share on other sites

Can you post the HTML for your form? Just the form from the opening <form ...> tag to the closing </form> tag.
I sure can
<form method="post" action="http://www.domainname.com/formmail/formmail.php" name="GeneralContact" /><input type="hidden" name="mail_options" value="HTMLTemplate=general.html,TemplateMissing=N/A,KeepLines" /><input type="hidden" name="template_list_sep" value="<br />" /><input type="hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER"><input type="hidden" name="recipients" value="general" /><input type="hidden" name="required" value="email:Your email address" /><input type="hidden" name="subject" value="General Contact from www.domainname.com" /><input type="hidden" name="good_url" value="http://www.domainname.com/contact/thanksyou.shtml" /><input type="hidden" name="bad_url" value="http://www.domainname.com/contact/error.shtml" /><div id="personal">	<table id="generalcontact">	  <tr>		<td class="lable">Contact Name:</td>		<td><input type="text" name="realname" size="65"></td>	  </tr>	  <tr>		<td class="lable">Phone Number:</td>		<td><input type="text" name="phone" size="20"></td>	  </tr>	  <tr>		<td class="lable">Phone Extention:</td>		<td><input type="text" name="ext" size="20"></td>	  </tr>	  <tr>		<td class="lable">Email Address (required):</td>		<td><input type="text" name="email" size="65"></td>	  </tr>	  <tr>		<td class="lable">Your Comments:</font></td>		<td><textarea rows="5" name="Comments" cols="50"></textarea></td>	  </tr>	  <tr>		<td> </td>		<td><input type="checkbox" name="ASAP" value="Yes">		  Immediate reply requested.</td>	  </tr>	  <tr>		<td class="submit" colspan="2">		  <p align="center"><input type="submit" value="Submit" name="B1"></td>	  </tr>

Not much to it but W3C just hates it. Here another example...<input type="hidden" name="template_list_sep" value="<br />" />This line simply tells the script what to pass to my templates. If, for example I replace the <br /> with a comma, I would receive an email that looks some thing like this...realname=data,phone=data,email=data.... etc.Using the break code the email is a little nicer...realname=dataphone=dataetc.

Link to comment
Share on other sites

OH... and this is what W3C has to say about the second example...

<input type="hidden" name="template_list_sep" value="<br />" />✉ This message may appear in several cases: •You tried to include the "<" character in your page: you should escape it as "<"•You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&", which is always safe.•Another possibility is that you forgot to close quotes in a previous tag.
Link to comment
Share on other sites

That's the whole form? Hmm....didn't see what I was looking for.What I'm specifically wondering is how does PHP get this information from the ini file:GeneralContact="email1,email2,email3"I thought it might have been a hidden input containing the name of the form or something. If you were to change the name of that form (you said you can do that, right?) where are all the locations you'd need to make changes to make it work?Unless maybe PHP can grab a form's name.... :)I'm sorry I'm not being much help, but this is a complicated script and without seeing it in person it's hard to figure out exactly what's going on. It may also be possible that this thing is way over my head, though too. :)OTOH, I can tell you that things like this:<p align="center">are invalid. The align attribute is deprecated as well as a lot of others. You should use CSS for that instead.

Link to comment
Share on other sites

OH... and this is what W3C has to say about the second example...
Do exactly as it says and write any '<' symbols as '& lt;' (without the space). The validator thinks you're trying to start a new tag every time it sees a '<' and gives you an error.
Link to comment
Share on other sites

I would attach the file but I don't see where I can do that if indeed I can. But I'd have to warn you that it is 12581 lines long. It is certainly over my head. Of course it can be downloaded for free at http://www.tectite.com/.Tectite is into data encription software and their script is very well documented on their website, so again I pretty sure it's me not doing something right.Doh, I missed the center tag. Well that's one off the list :) When you help some one you are never failing to help. I appreciate everyones efforts including your.

Link to comment
Share on other sites

Do exactly as it says and write any '<' symbols as '& lt;' (without the space). The validator thinks you're trying to start a new tag every time it sees a '<' and gives you an error.
I actually did try that and ended up with an email....
realname=date<phone=data<email=data<.... etc

Link to comment
Share on other sites

Doh, I missed the center tag. Well that's one off the list
I think the validator will complain about <center> too. Use <p style='text-align: center;'> instead.
I actually did try that and ended up with an email....
realname=date<phone=data<email=data<.... etc

Hmm...weird. I just did a quick test with this:
<input type='hidden' name='testHTML' value='<span>Span with some text</span>' />.....if (isset($_POST['testHTML'])) {	echo $_POST['testHTML'];}

and it worked just fine. Perhaps the script is escaping (or actually unescaping it I guess :)) it using htmlentities or some such.Unfortunately, I can't download the file 'cuz I'm at work. :)EDIT: I think justsomeguy needs to mozie on over here.... :) He's the resident PHP expert.

Link to comment
Share on other sites

I think the validator will complain about <center> too. Use <p style='text-align: center;'> instead.Hmm...weird. I just did a quick test with this:
<input type='hidden' name='testHTML' value='<span>Span with some text</span>' />.....if (isset($_POST['testHTML'])) {	echo $_POST['testHTML'];}

and it worked just fine. Perhaps the script is escaping (or actually unescaping it I guess :)) it using htmlentities or some such.Unfortunately, I can't download the file 'cuz I'm at work. :)EDIT: I think justsomeguy needs to mozie on over here.... :) He's the resident PHP expert.

ShadowMage, you’ve been a lot of help… you got me thinking.I was being lazy at the time I created the form and scabbed on old form I created from an old form I had from my FrontPage days. Maybe I don’t need the name=anything in there at all.I just realized that the it’s the <input type="hidden" name="recipients" value="general" />Line that actually passes the right value to the script.When I opened the ini file to change GeneralContact it was just plan old general=I’m going to try and get rid of a few things as I think<input type="hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER" />Might be left over garbage from frontpage as well.I’ll go play and delete some things I’m starting to wonder about thanks to you!I’ll let you know in a while how things are going.
Link to comment
Share on other sites

I just realized that the it’s the <input type="hidden" name="recipients" value="general" />Line that actually passes the right value to the script.
Bingo! That's what I was originally looking for when I asked you to post your form. :)
I’ll go play and delete some things I’m starting to wonder about thanks to you!I’ll let you know in a while how things are going.
Keep me posted. :)
Link to comment
Share on other sites

OK, now I am really confused. I decided to switch to my "webmaster" form as I didn't want to whipe out my main contact form. I have stripped this form down to nothing. I figured if I started with a page that couldn't fail and slowly add back elements and deal with those errors on a one by one basis. So this form is empty and still W3C reports 32 errors with it. Including 3 just about my closing html code.Here is my entire page... I just can't figure it out. I guess I will just start with a blank page again.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title> Is It My Name </title><link rel="stylesheet" type="text/css" media="screen" href="../css/contactform.css" /><link rel="stylesheet" type="text/css" media="screen" href="../css/layout.css" /></head><body><div id="container"><h1>Webmaster Contact Form</h1><div class="onecolumn"><p>Fields indicated with an asterisk (*) are required to submit this form.</p><div id="personal"><form method="post" action="http://www.domainname.com/formmail/formmail.php">	<table id="generalcontact">		<tr>			<td class="lable">* Reason for Contact:</td>			<td>			<select size="1" name="Reason4Contact">			<option></option>			<option>404 - Page Not Found Error</option>			<option>401 - Access Denied Error</option>			<option>Spelling / Grammar Error</option>			<option>Suggestion</option>			<option>Question</option>			<option>Website Development Inquiry</option>			<option>Other</option>			</select>			</td>		</tr>		<tr>			<td class="lable">Contact Name:</td>			<td><input type="text" name="realname" size="65"></td>		</tr>		<tr>			<td class="lable">Phone Number:</td>			<td><input type="text" name="phone" size="20"></td>		</tr>		<tr>			<td class="lable">Phone Extention:</td>			<td><input type="text" name="ext" size="20"></td>		</tr>		<tr>			<td class="lable">* Email Address:</td>			<td><input type="text" name="email" size="65"></td>		</tr>		<tr>			<td class="lable">* Your Comments:</td>			<td><textarea rows="5" name="Comments" cols="50"></textarea></td>		</tr>		<tr>			<td> </td>			<td><input type="checkbox" name="ASAP" value="Yes">Immediate reply requested.</td>		</tr>		<tr>			<td class="submit" colspan="2">			<p><input type="submit" value="Submit" name="B1"></p>			</td>		</tr>	</table></form></div> <!-- end of personal --></div> <!-- end of onecolumn --></div> <!-- end of container --><div id="header"><div class="center"><!--#include virtual = "../common/logo.html" --></div><!--#include virtual = "../common/menu.html" --></div><div id="footer"><!--#include virtual = "../common/footer.html" --></div></body></html>

:)

Link to comment
Share on other sites

I've gone one step further. Starting with a complete sheet no form and no table. PassedI added the form and a blank table. PassedI added the first table row and form field (option box). PassedI add the second table row and form field (text box). FailedSo from here on I'll just include the table.Passes:

<table id="generalcontact"><tr><td class="lable">* Reason for Contact:</td><td><select size="1" name="Reason4Contact"><option></option><option>404 - Page Not Found Error</option><option>401 - Access Denied Error</option><option>Spelling / Grammar Error</option><option>Suggestion</option><option>Question</option><option>Website Development Inquiry</option><option>Other</option></select></td></tr><tr>	<td> </td>	<td> </td></tr><tr>	<td> </td>	<td> </td></tr></table>

Fails:

<table id="generalcontact"><tr><td class="lable">* Reason for Contact:</td><td><select size="1" name="Reason4Contact"><option></option><option>404 - Page Not Found Error</option><option>401 - Access Denied Error</option><option>Spelling / Grammar Error</option><option>Suggestion</option><option>Question</option><option>Website Development Inquiry</option><option>Other</option></select></td></tr><tr><td class="lable">Contact Name:</td><td><input type="text" name="realname" size="65"></td></tr><tr>	<td> </td>	<td> </td></tr><tr>	<td> </td>	<td> </td></tr></table>

It actually fails with 9 errors and I sure can not figure out what their error message are hinting at. I just don't see it. Here's a few of them...Line 41, Column 54: end tag for "input" omitted, but OMITTAG NO was specified <td><input type="text" name="realname" size="65"></td>You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">". Line 41, Column 5: start tag was here <td><input type="text" name="realname" size="65"></td>Line 41, Column 54: Opening and ending tag mismatch: input line 41 and td <td><input type="text" name="realname" size="65"></td>And then it goes on to complain about everything from the next table row tag to the closing html tag. I remove the offending tag and again passed. So I went on to the next row (phone number) and it failed again.That's where I'm at.Cheers,

Link to comment
Share on other sites

THE BIG UPDATE...It took 18 hours and my eyes are bleeding, BUT IT VARIFIED!!!I did have to add an element, fail, read, learn, try, read some more, try again... OK you get the idea.But all said and done it looks like I've finally got it.Thanks so much Shadow. You were a huge help! :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...