Hi I have a javascript in my document whic contains "<" like this: if(document.getElementById('user_comment').value.length < 10) PHP: even though it is inside an script tag still xhtml gives me a warning. What do I do then?
If you want to validate XHTML, you must use this style for your JavaScripts: <script type="text/javascript"> //<![CDATA[ alert("<This is compatible with XHTML>"); //]]> </script> HTML: via Making JavaScript Compatible with XHTML
Alternatively, you could externalize your code snippet into a Javascript file so that it's separate from your output code. Something like this in your <head> tag: <script type="text/javascript" src="form_validation_by_mahmood.js"> <!-- <![CDATA[ ]]> --> </script> Code (markup): form_validation_by_mahmood.js would contain your function. From there, you'd just call your function the same as you normally would (assuming you put your JScript into a function.) Personally, I recommend doing this, since it separates your Javascript output from your HTML output, thus making it easier to debug. I'm also not sure, but I remember reading somewhere that JScripts tend to perform slightly more efficiently this way, especially in situations where the JScript can be cached.