Why doesn't the W3C validator work in this JS code?

I am trying to make an XHTML 1.0 Transitional page compatible. One of the problems that the validator has with my code is in the following line:

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

Error:

the & character is the first delimiter character, but takes place as data

Here is another problematic line:

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

Again, the error is this:

the & character is the first delimiter character, but takes place as data

How to fix it?

+4
source share
3 answers

I assume your javascript codes are not porperly closed.

Look at here:
Proper use of 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> 
+7
source

Wrap it in CDATA:

 <script type="text/javascript"> //<![CDATA[ Javascript here //]]> </script> 
+4
source

Javascript code must be placed in a CDATA declaration to pass XHTML validation.

+1
source

All Articles