Alex Rivera | Logout

XHTML won't validate && and < in a JavaScript function

Asked 2009-10-03T14:30:00.093
15

Here's the snippet of code that won't validate:

if (user_age > 15 && user_age < 91)

It gets the following errors:

XML Parsing Error: StartTag: invalid element name

and

XML Parsing Error: xmlParseEntityRef: no name

The first error is thrown for the "less than" and the second one is thrown twice, once for each ampersand.

Replacing the above signs with & and < validates fine, but of course it completely ruins the function.

Edit
Report

1 Answer

1

put javascript in <![CDATA[...]]> section

answered 2009-10-03T14:33:45.040

Your Answer