Reputation: 32765
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?
Upvotes: 4
Views: 5794
Reputation: 11977
Javascript code should be placed within a CDATA declaration in order to pass XHTML validation.
Upvotes: 1
Reputation: 25810
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>
Upvotes: 7
Reputation: 57658
Wrap it in CDATA:
<script type="text/javascript">
//<![CDATA[
Javascript here
//]]>
</script>
Upvotes: 4