Validating <textarea>

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dennis Allen

    Validating <textarea>

    Hi. I hope someone here can help. I'm webmaster for a local astronomy
    club. Just went over our web site. Have validated every htm file on the
    site except:


    In the <textarea> of this page I have Javascript code. I can't figure out
    how to present this code and still be w3c valid. Any advice would be
    appreciated...D ennis


  • Christopher Finke

    #2
    Re: Validating &lt;textarea&gt ;

    "Dennis Allen" <dennis@dennisa llen.com> wrote in message
    news:100k5jf9kf 33g27@corp.supe rnews.com...[color=blue]
    > Hi. I hope someone here can help. I'm webmaster for a local astronomy
    > club. Just went over our web site. Have validated every htm file on the
    > site except:
    > http://validator.w3.org/check?uri=ht.../mas/COMET.htm
    >
    > In the <textarea> of this page I have Javascript code. I can't figure out
    > how to present this code and still be w3c valid. Any advice would be
    > appreciated...D ennis[/color]

    Do a search and replace on the code inside the textarea, and change all
    opening angle brackets ("<") to "&lt;" and all closing angle brackets (">")
    to "&gt;". The code will validate, and the text inside the textarea will
    appear the same.

    Christopher Finke


    Comment

    • Jukka K. Korpela

      #3
      Re: Validating &lt;textarea&gt ;

      "Dennis Allen" <dennis@dennisa llen.com> wrote:
      [color=blue]
      > Have validated every htm file on the
      > site except:
      > http://validator.w3.org/check?uri=ht...g.net/mas/COME
      > T.htm[/color]

      That's not an "htm file" but a reference to a validator so that the URL
      of a page is passed to it. Actually, not even that, since
      "Within a query component, the characters ;, /, ?, :, @, &, =, +, ,,
      and $ are reserved." (RFC 2396), so the reference is syntactically
      malformed.
      [color=blue]
      > In the <textarea> of this page I have Javascript code. I can't
      > figure out how to present this code and still be w3c valid.[/color]

      Why do you use a form input field when you don't want any user input?

      Just put the Javascript code into a separate file and link to it, on a
      page that explains what the code does, if you think the code is useful.
      If the user's browser starts actually executing Javascript code when he
      follows the link, then this will be a useful lesson, and a cheap one as
      compared with the possibility of following an innocent-looking link
      using a Javascript-enabled browser.

      If you insist on embedding Javascript code as visible text onto your
      HTML document, then make it really visible, inside <pre> element for
      example, instead of forcing the user play with a separately scrollable
      area inside a scrollable window.

      In any case, any "<" and "&" as data characters in HTML should be
      written as "&lt;" and "&amp;". (Using "&gt;" for ">" is never required
      by HTML rules, but you might do it for symmetry, or to cope with some
      assumed bugs in ancient browsers.) A rhetorical question: are you
      qualified to make recommendations to other people about what they
      should put into their HTML documents, if you were not able to figure
      out this elementary HTML thing on your own?

      --
      Yucca, http://www.cs.tut.fi/~jkorpela/
      Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

      Comment

      • Dennis Allen

        #4
        Re: Validating &lt;textarea&gt ;

        Just want I needed to know. Thanks...Dennis

        "Christophe r Finke" <christopherfin ke@hotmail.com> wrote in message
        news:bud71v$gi1 mu$1@ID-158177.news.uni-berlin.de...[color=blue]
        > "Dennis Allen" <dennis@dennisa llen.com> wrote in message
        > news:100k5jf9kf 33g27@corp.supe rnews.com...[color=green]
        > > Hi. I hope someone here can help. I'm webmaster for a local astronomy
        > > club. Just went over our web site. Have validated every htm file on[/color][/color]
        the[color=blue][color=green]
        > > site except:
        > >[/color][/color]
        http://validator.w3.org/check?uri=ht.../mas/COMET.htm[color=blue][color=green]
        > >
        > > In the <textarea> of this page I have Javascript code. I can't figure[/color][/color]
        out[color=blue][color=green]
        > > how to present this code and still be w3c valid. Any advice would be
        > > appreciated...D ennis[/color]
        >
        > Do a search and replace on the code inside the textarea, and change all
        > opening angle brackets ("<") to "&lt;" and all closing angle brackets[/color]
        (">")[color=blue]
        > to "&gt;". The code will validate, and the text inside the textarea will
        > appear the same.
        >
        > Christopher Finke
        >
        >[/color]


        Comment

        • Dennis Allen

          #5
          Re: Validating &lt;textarea&gt ;

          That's what I need to know. Thanks...Dennis

          "Jukka K. Korpela" <jkorpela@cs.tu t.fi> wrote in message
          news:Xns9474652 C6FF79jkorpelac stutfi@193.229. 0.31...[color=blue]
          > In any case, any "<" and "&" as data characters in HTML should be
          > written as "&lt;" and "&amp;". (Using "&gt;" for ">" is never required
          > by HTML rules, but you might do it for symmetry, or to cope with some
          > assumed bugs in ancient browsers.) A rhetorical question: are you
          > qualified to make recommendations to other people about what they
          > should put into their HTML documents, if you were not able to figure
          > out this elementary HTML thing on your own?
          >
          > --
          > Yucca, http://www.cs.tut.fi/~jkorpela/
          > Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
          >[/color]


          Comment

          Working...