tags:

views:

323

answers:

1

Hello!

I try to validate my xhtml and i have a little problem with this:

The end of the document i have this little JS script which contain IMG and FONT tags, and i get error for this: document type does not allow element "img" here; document type does not allow element "font" here

$("#nick_name").change(function()
 {var usr=$("#nick_name").val();if(usr.length>=4)
 {$("#status").html('<img src="images/loader.gif" align="middle" alt="" title=""/>');
.
.
.

How can i validate this?

Thank you.

+4  A: 

Put the script in a CDATA to validate; details. I found it is a good practice when dealing with javascript and validation.

Something like this

<script type="text/javascript">
<![CDATA[

$("#nick_name").change(function()
 {var usr=$("#nick_name").val();if(usr.length>=4)
 {$("#status").html('<img src="images/loader.gif" align="middle" alt="" title=""/>');
.
.
.
]]>
</script>
Eineki
+1 Beat me by seconds, added a link.
T.J. Crowder
my script not work if i modify as you mentioned..
Holian
@T.J.: I don't know much about this..W3C say valid XHTML..(if its matter..) But never mind, i put this part to an outside JS and so i can validate. Thank you for your help.
Holian
@Holian: Happy to. Here's that link again: http://hixie.ch/advocacy/xhtml (I deleted my comment earlier thinking you'd fixed this without moving to an external file, I just didn't read thoroughly enough before clicking delete.) My other suggestion in that comment was to try putting a line comment in front of the tags (e.g., `// <![CDATA[` and `// ]]>`), but I wouldn't think that was necessary with browsers that really do know they're processing XHTML.
T.J. Crowder
Thank you again! I really appreciate your help..
Holian