Textarea and valid HTML

A

Andrew Poulos

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
 
R

Randy Webb

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.
 
A

Andrew Poulos

Randy said:
Andrew Poulos said the following on 2/12/2007 10:29 PM:

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: said:
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
 
I

Ian Collins

Andrew said:
I get 3 specific errors:
- Warning: discarding unexpected </textarea>
- Warning: <url:> attribute "http://www.foo.com" lacks value
- Error: <url:> is not recognized!


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.
 
M

marss

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

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

Andrew Poulos

marss said:
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


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
 
R

Randy Webb

Andrew Poulos said the following on 2/13/2007 5:45 AM:
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.
 
I

Ian Collins

Andrew said:
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.
 
D

Dr J R Stockton

In comp.lang.javascript message said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top