Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the W3C Validator fail on this JS code?

I'm trying to make a page XHTML 1.0 Transitional compliant. One of the issues the Validator has with my code lies within the following line:

if (isNumeric(code) && code.length == 4) {

Error:

character "&" is the first character of a delimiter but occurred as data

Here's another problematic line:

aData = data.split("&&");

Again, the error is this:

character "&" is the first character of a delimiter but occurred as data

How do I fix this?

like image 686
Pieter Avatar asked Dec 17 '22 04:12

Pieter


1 Answers

My guess is your javascript codes are not enclosed porperly.

Take a look here:
Properly Using CSS and JavaScript in XHTML Documents

Exceprt:

<script type="text/javascript">
  var i = 0;

  while (++i < 10)
  {
    // ...
  }
</script>

VS

<script type="text/javascript">
 //<![CDATA[
  var i = 0;

  while  (++i < 10)
  {
    // ...
  }
 //]]>
</script>
like image 169
o.k.w Avatar answered Dec 23 '22 20:12

o.k.w