Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

W3C HTML Validator Validating Javascript 1

Status
Not open for further replies.

Graeme06

Technical User
Jun 6, 2006
60
Hi, the last of three validation problems I'm having. I have a page with some Javascript, and this Javascript has a String declaration along the lines of:

word = "the word \"this\" is in quotations".

For it to work correctly, I need the escape character, but the validator gives me the message:
"an attribute value must be a literal unless it contains only name characters."

It isn't just this specific issue, it also complains about me joining two strings with the + character.

Why is this? Is there a way to stop Javascript from being validated?

Thanks,
Graeme
 
There sure is, just use the cdata tags like so:
Code:
<script type="text/javascript">
[!]/*<![CDATA[*/[/!]
var a = "this javascript will be skipped by the validator";
[!]/*]]>*/[/!]
</script>

-kaht

Looking for a puppy?

silky-icon-left.gif
[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
silky-icon-right.gif
 
awesome!

Thanks a lot, I figured there had to be some way, it made no sense if there wasn't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top