Validating XHTML with javascript in the code - TechRepublic
Question
February 13, 2009 at 12:15 AM
lynda

Validating XHTML with javascript in the code

by lynda . Updated 17 years, 4 months ago

Hello, all. Although I’ve been creating web pages for nearly 15 years, I’ve only recently stopped being lazy and started making sure I write valid, compliant code. Long story – don’t ask.

It’s very possible that this is obvious to everyone but me. However, I decided a long time ago that there are no stupid questions, so here goes.

http://validator.w3.org/ has become my best friend/worst enemy. Now I’m finding that the validator is callikng javascript code within tags invalid XHTML code, which of course keeps my pages from validating. For example:

[code]
# Line 72, Column 33: character “<" is the first character of a delimiter but occurred as data. } else if ((fld.value.length < 1) || (fld.value.length > 10)) {

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. # Error Line 72, Column 34: XML Parsing Error: StartTag: invalid element name. } else if ((fld.value.length < 1) || (fld.value.length > 10)) {
[/code]

This is the only warning, and the only error, on the page.

The entire code block is
[code]

[/code]

I didn’t write the code, I’m validating a site created by someone else who isn’t available right now, and I’m pretty sure he wouldn’t have the answer, anyway. I don’t know Javascript, although I understand programming logic and have a vague idea of what this does.

All the paired elements – parens, quotes, braces, and the

This discussion is locked

All Comments