views:

124

answers:

4

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?

A: 

Is this code embedded in valid script-Tags?

Tim
+1  A: 

Wrap it in CDATA:

<script type="text/javascript">
//<![CDATA[

Javascript here

//]]>
</script> 
Zed
+1  A: 

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>
o.k.w
+1  A: 

Javascript code should be placed within a CDATA declaration in order to pass XHTML validation.

Alexander Gyoshev