1

I'm having a little problem to validate a html page with a js script.

i have this js part : " .

var lastPage = this.getNumPages() - 1;

if (this.displayedPage < lastPage)

nextPageLink.css('visibility', 'visible');

Everything works fine but i have 1 error remaining when i try to validate it:

Line 856, Column 30: character is the first character of a delimiter but occurred as data if (this.displayedPage < lastPage)

✉ 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.

Line 856, Column 30: StartTag: invalid element name if (this.displayedPage < lastPage)

I just want a way to replace the < sign with something that works whit my script and will pass the W3C validation.

Shakashi
  • 13
  • 2
  • Remember that validation isn't as important as you may think. They often want to do some extra footwork that really isn't necessary. I suspect something like that is going on here. – Alex Wayne Nov 19 '11 at 22:50

2 Answers2

2

You need to declare your JavaScript as cdata. The < symbol is interpreted as part of a tag, causing the error.

When is a CDATA section necessary within a script tag?

Community
  • 1
  • 1
Kylos
  • 1,888
  • 14
  • 24
1

You could use <script type="text/javascript" src=""></script> to load your javascript file instead of putting it in your htmle file.

qw3n
  • 6,236
  • 6
  • 33
  • 62