View Full Version : Validating Page
07-07-2005, 10:29 PM
Well I am using this password script
on this page : http://home.comcast.net/~allbonz89/validate/index.htm (not actualy page but reproduction because actual page is in password protected directory but is the exact same content just without pages that you go to.)
Now I am trying to validate it using this http://validator.w3.org/ validator. It is telling me that the ampersands in the script are invalid. When I try to add the & it doesnt work. The validator keeps telling me that it is a URL but it is not. Does anyone know how to make this valid? I am thinking about putting the scripts in another folder but how to you link the functions in the scripts to the forms?
Oh yeah just in case anyone says anything... THIS IS NOT ABOUT PUTTING MULTIPLE SCRIPTS ON A PAGE
07-07-2005, 11:37 PM
In the url, try '%26' in place of '&' or, as you have it now '&'. In the conditionals, try rewriting them as - Ex:
07-08-2005, 12:07 AM
Thank you... you helped bring my errors on page down to three... You can see what I changed on the page.. I left the && there I just used the conditional statement that you posted instead of the old one. Now the only errors on the page are the closing tags on my scripts. The validator says that there is no script open.
07-08-2005, 01:01 AM
I didn't take a thorough look originally (I now wish I had as you've edited the markup), but all of your errors were due to missing quotes on the type attributes on both your style and script elements.
HTML is an application of SGML and as such, possesses certain notation features. Because they were rarely used, and browsers have never really been proper SGML processing agents, these features are largely ignored but an SGML validator, like the one provided by the W3C still honour them.
The feature in question here is the SHORTTAG, and more specifically, NET tags. What this allows is a shorthand approach to including HTML elements. Instead of writing:
I <strong>really</strong> need your help.you could abbreviate it to:
I <strong/really/ need your help.Basically, you use slashes to delimit where the start tag and content ends, replacing the end tag with a single slash:
<tag attributes/content/Your style element, for example looks like this to the validator:
/* ... */
</style>This is fine as HTML is concerned, but nonsense for CSS.
The script elements, however, prove more troublesome because of the slashes used in the comments. As the first slash in the style element doesn't occur until the closing tag, everything's reasonably fine, but it will close early for the script:
/Encrypted Password script- By Rob Heslop
//Script featured on Dynamic Drive
/* ... */Notice the first comment is missing one of its two slashes.
The validator then encounters ampersands outside an element, so it complains that it doesn't understand them as entity references. It then finds a closing script tag, despite the fact that the NET tag earlier on already closed it, so it complains about that, too.
I'll understand if you didn't get that explanation. It's obscure, but I thought I'd at least prove that there is a reason for this behaviour. The important lesson is that unless you know when you can omit quotes around attribute values, never do so. Though browsers won't flip out as badly as the validator does, they will invariably have problems that you might not notice until someone tells you that feature X doesn't work in browser Y.
Note that John's fix with regard to the expressions wasn't necessary. That simply stopped the validator from considering them as entity references. However, if it parsed the script as you intended it do, the validator would have just considered them plain text anyway. It was coincidence, really.
One final note: this really didn't have anything to do with accessibility. It was a HTML question. :)
 With the possible exception of literal ampersands (&) in attributes. The only URL that might have originally contained them was off the right-hand edge of my screen, so I didn't see it until John mentioned it.
 Elements like script and style have their content marked as CDATA - a data type in SGML. Entity references like & aren't expanded, which is why literal ampersands (&) are acceptable. Note that entity references are expanded in attributes (even if they are CDATA) and in most other elements, too.
07-08-2005, 01:16 AM
Ahh I see what you mean... I followed but I had to read it a couple times... so I just needed to add quotes... I could kiss you :) Lol.. sorry this is a big accomplishment for me since I have been trying all day to find this solution. You were absolutly wonderful and you most definatly know your stuff.
07-08-2005, 01:38 AM
Ahh I see what you mean... I followed but I had to read it a couple times...I've edited the explanation slightly, so hopefully it's a little easier to read. Sorry, but I was rushing so I could go to sleep. :D
so I just needed to add quotesYeah, I could have just said that, but then you wouldn't have known why. ;)
You were absolutly wonderful and you most definatly know your stuff.It's just a matter of time. Even the obscure points of HTML aren't difficult to understand (at least when you get good explanations - that one's still rushed :o), but you will have trouble finding places that explain them on the Web.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.