By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,882 Members | 2,482 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,882 IT Pros & Developers. It's quick & easy.

Validating <textarea>

P: n/a
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...Dennis
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Dennis Allen" <de****@dennisallen.com> wrote in message
news:10*************@corp.supernews.com...
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...Dennis


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
Jul 20 '05 #2

P: n/a
"Dennis Allen" <de****@dennisallen.com> wrote:
Have validated every htm file on the
site except:
http://validator.w3.org/check?uri=ht...g.net/mas/COME
T.htm
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.
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.


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

Jul 20 '05 #3

P: n/a
Just want I needed to know. Thanks...Dennis

"Christopher Finke" <ch**************@hotmail.com> wrote in message
news:bu************@ID-158177.news.uni-berlin.de...
"Dennis Allen" <de****@dennisallen.com> wrote in message
news:10*************@corp.supernews.com...
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...Dennis
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

Jul 20 '05 #4

P: n/a
That's what I need to know. Thanks...Dennis

"Jukka K. Korpela" <jk******@cs.tut.fi> wrote in message
news:Xn*****************************@193.229.0.31. ..
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

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.