469,344 Members | 6,547 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,344 developers. It's quick & easy.

Textarea and valid HTML

I'm dynamically populating a TEXTAREA with some info that includes a
URL. Eg.

frm.value = "This is the link to use <url: http://www.foo.com >";

but this results in a page that doesn't validate. I tried escaping the
value but then I get entities displaying in the TEXTAREA.

Is there a way to change the value without upsetting the page's validation?

Andrew Poulos
Feb 13 '07 #1
9 2135
Andrew Poulos said the following on 2/12/2007 10:29 PM:
I'm dynamically populating a TEXTAREA with some info that includes a
URL. Eg.

frm.value = "This is the link to use <url: http://www.foo.com >";

but this results in a page that doesn't validate.
What does it complain about? The <url tag?
I tried escaping the value but then I get entities displaying in the TEXTAREA.
Is there a way to change the value without upsetting the page's validation?
Put the script in an external file, the validator will never see it.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 13 '07 #2
Randy Webb wrote:
Andrew Poulos said the following on 2/12/2007 10:29 PM:
>I'm dynamically populating a TEXTAREA with some info that includes a
URL. Eg.

frm.value = "This is the link to use <url: http://www.foo.com >";

but this results in a page that doesn't validate.

What does it complain about? The <url tag?
I get 3 specific errors:
- Warning: discarding unexpected </textarea>
- Warning: <url:attribute "http://www.foo.com" lacks value
- Error: <url:is not recognized!
>I tried escaping the value but then I get entities displaying in the
TEXTAREA.
Is there a way to change the value without upsetting the page's
validation?

Put the script in an external file, the validator will never see it.
It's not the script per se but the content of the TEXTAREA that is
causing the validator to barf.

Andrew Poulos
Feb 13 '07 #3
Andrew Poulos wrote:
Randy Webb wrote:
>Andrew Poulos said the following on 2/12/2007 10:29 PM:
>>I'm dynamically populating a TEXTAREA with some info that includes a
URL. Eg.

frm.value = "This is the link to use <url: http://www.foo.com >";

but this results in a page that doesn't validate.


What does it complain about? The <url tag?

I get 3 specific errors:
- Warning: discarding unexpected </textarea>
- Warning: <url:attribute "http://www.foo.com" lacks value
- Error: <url:is not recognized!
That's because <url: http://www.foo.com isn't a well formed HTML tag.
>>I tried escaping the value but then I get entities displaying in the
TEXTAREA.
Is there a way to change the value without upsetting the page's
validation?


Put the script in an external file, the validator will never see it.

It's not the script per se but the content of the TEXTAREA that is
causing the validator to barf.
So the validator validating the page after your script has modified it.
If the script where in another file, the validation might not include it.

--
Ian Collins.
Feb 13 '07 #4

Andrew Poulos wrote:
>>I get 3 specific errors:
- Warning: discarding unexpected </textarea>
- Warning: <url:attribute "http://www.foo.com" lacks value
- Error: <url:is not recognized!
I guess you use XHTML validation. So validator does not like the
unknown unclosed tag <url:with incorrect attribute. You can avoid it
if you change "This is the link to use <url: http://www.foo.com >" to
plain text. Replace < with &lt; and replace with &gt;.
>frm.value = "This is the link to use <url: http://www.foo.com >";
frm is textarea, yes?
Try this.
frm.innerHTML = "This is the link to use &lt;url: http://www.foo.com
&gt;";

Feb 13 '07 #5
Replace < with &lt; and replace with &gt;

Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.

On Tue, 13 Feb 2007 14:29:50 +1100, Andrew Poulos
<ap*****@hotmail.comwrote:
>frm.value = "This is the link to use <url: http://www.foo.com >";
Feb 13 '07 #6
marss wrote:
Andrew Poulos wrote:
>>I get 3 specific errors:
- Warning: discarding unexpected </textarea>
- Warning: <url:attribute "http://www.foo.com" lacks value
- Error: <url:is not recognized!

I guess you use XHTML validation. So validator does not like the
unknown unclosed tag <url:with incorrect attribute. You can avoid it
if you change "This is the link to use <url: http://www.foo.com >" to
plain text. Replace < with &lt; and replace with &gt;.
>>frm.value = "This is the link to use <url: http://www.foo.com >";

frm is textarea, yes?
Try this.
frm.innerHTML = "This is the link to use &lt;url: http://www.foo.com
&gt;";
Actually, in my initial tests I use the TIDY add-on for FF 2.

Unfortunately I think I have to put up with it not being valid as using
the method above displays &alt; and not < in the TEXTAREA.

Andrew Poulos
Feb 13 '07 #7
Andrew Poulos said the following on 2/13/2007 5:45 AM:
marss wrote:
>Andrew Poulos wrote:
>>>I get 3 specific errors:
- Warning: discarding unexpected </textarea>
- Warning: <url:attribute "http://www.foo.com" lacks value
- Error: <url:is not recognized!

I guess you use XHTML validation. So validator does not like the
unknown unclosed tag <url:with incorrect attribute. You can avoid it
if you change "This is the link to use <url: http://www.foo.com >" to
plain text. Replace < with &lt; and replace with &gt;.
>>>frm.value = "This is the link to use <url: http://www.foo.com >";

frm is textarea, yes?
Try this.
frm.innerHTML = "This is the link to use &lt;url: http://www.foo.com
&gt;";

Actually, in my initial tests I use the TIDY add-on for FF 2.
Unfortunately I think I have to put up with it not being valid as using
the method above displays &alt; and not < in the TEXTAREA.
What does the W3C Validator say about the same code? If the W3C
Validator doesn't complain but Tidy does then Tidy is the culprit, not
your HTML.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 13 '07 #8
Andrew Poulos wrote:
marss wrote:
>Andrew Poulos wrote:
>>>I get 3 specific errors:
- Warning: discarding unexpected </textarea>
- Warning: <url:attribute "http://www.foo.com" lacks value
- Error: <url:is not recognized!


I guess you use XHTML validation. So validator does not like the
unknown unclosed tag <url:with incorrect attribute. You can avoid it
if you change "This is the link to use <url: http://www.foo.com >" to
plain text. Replace < with &lt; and replace with &gt;.
>>>frm.value = "This is the link to use <url: http://www.foo.com >";


frm is textarea, yes?
Try this.
frm.innerHTML = "This is the link to use &lt;url: http://www.foo.com
&gt;";

Actually, in my initial tests I use the TIDY add-on for FF 2.
So the page is being validated after the script has run?

Use the W3C validator.

--
Ian Collins.
Feb 14 '07 #9
In comp.lang.javascript message <L8********************@telcove.net>,
Tue, 13 Feb 2007 18:48:13, Randy Webb <Hi************@aol.composted:
>
What does the W3C Validator say about the same code? If the W3C
Validator doesn't complain but Tidy does then Tidy is the culprit, not
your HTML.
That may be so for Genuine Errors.

But :

(1) Tidy gives by default warnings which are not by default given by
<http://validator.w3.org/>.

(2) <http://validator.w3.org/gives up on at least one page - an ISP's
Home Page, forsooth - for which TIDY will happily report usefully on a
local copy. W3 hates characters not in the character set.

IMHO, it's worth using both. I have a batch file which runs TIDY and
various other tests (including checking for 8061) on any HTML page here
that's changed since the last time, stopping on error but otherwise
running to completion.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zipTimo Salmi's Turbo Pascal FAQ.
Feb 15 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by entoone | last post: by
3 posts views Thread by Gadrin77 | last post: by
4 posts views Thread by Simon | last post: by
5 posts views Thread by lawrence | last post: by
11 posts views Thread by Les Paul | last post: by
1 post views Thread by Garry Jones | last post: by
20 posts views Thread by Tony B | last post: by
15 posts views Thread by globalrev | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.