SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: validation

  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    validation

    Anyone enlighten me as to why the following javascript won't validate as xhtml transitional? Or better, how to change it so it will?

    <script type="text/javascript">

    /***********************************************
    * Encrypt Email script- Please keep notice intact.
    * Tool URL: http://www.dynamicdrive.com/emailriddler/
    * **********************************************/

    var emailarray1170= new Array(121,111,117,64,121,111,117,114,100,111,109,97,105,110,46,99,111,109)
    var postemail1170=''
    for (i=0;i<emailarray1170.length;i++)
    postemail1170+=String.fromCharCode(emailarray1170[i])

    document.write('<a href="mailto:'+postemail1170+'">Contact Us</a>')

    </script>

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,604
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Because it is javascript and not XHTML. Either move it out of the XHTML document or identify it as data instead of XHTML.

    Code:
    <script type="text/javascript">
    /* <![CDATA[ */
    // content of your Javascript goes here
    /* ]]> */
    </script>
    also note that document.write cannot be used with XHTML.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks

    You first sentence made me chuckle at how little I know. Anyway, using the tag solved the issue and it the page now validates. I'll have to read up more about document.write.
    For anyone else reading this thread that wants more detail about javascript and xhtml validation, I subsequently found this article which explains the issue I had and the solution kindly provided by the guru above.

    http://javascript.about.com/library/blxhtml.htm


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •