# validating for(var i=0;i < ca.length;i++)



## adlamb (Nov 5, 2004)

That's it really, the < in that expression will not validate:



> # Warning Line 37, Column 16: character "<" is the first character of a delimiter but occurred as data
> 
> for(var i=0;i < ca.length;i++) {
> 
> ...


Anyone any thoughts?
Sorry for my ignorance, I'm not too good with javascript...although rapidly getting better!

the scrpit in question:



> function readCookie(name) {
> var nameEQ = name + "=";
> var ca = document.cookie.split(';');
> for(var i=0;i < ca.length;i++) {
> ...


----------



## MMJ (Oct 15, 2006)

That code is fine.


----------



## adlamb (Nov 5, 2004)

Thanks again!
I wonder why I am still getting a validation error on that < .
There seems to be nothing before it that I haven't closed.


----------



## MMJ (Oct 15, 2006)

what is giving you that error?

does the code run at all?


----------



## Big-K (Nov 22, 2003)

Sounds like you're validating with an XHTML doctype. Since XHTML is based on XML, certain characters, including <, MUST be encoded to validate. This can be worked around with CDATA indicators, which mark up areas of text that should not be processed as XML, like so:


```
<script>
<![CDATA[
for(i = 0; i < 5; i++);
]]>
</script>
```


----------



## MMJ (Oct 15, 2006)

Big-K said:


> Sounds like you're validating with an XHTML doctype. Since XHTML is based on XML, certain characters, including <, MUST be encoded to validate. This can be worked around with CDATA indicators, which mark up areas of text that should not be processed as XML, like so:
> 
> 
> ```
> ...


ahaha, right you are. I wasn't even paying attention and thought he couldn't get the code to run.

btw, you might want to put javascript comments before CDATA.


```

```


----------



## adlamb (Nov 5, 2004)

XHTML PASSED 

Thanks.
I haven't changed any of the css and now I'm getting 3 background errors (and wasn't before). I pretty sure its unrelated tho......a job for tomorrow now I think. Thanks for your help.


----------

