Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Textarea and valid HTML

Reply
Thread Tools

Textarea and valid HTML

 
 
Andrew Poulos
Guest
Posts: n/a
 
      02-13-2007
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
 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      02-13-2007
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/
 
Reply With Quote
 
 
 
 
Andrew Poulos
Guest
Posts: n/a
 
      02-13-2007
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
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      02-13-2007
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.
 
Reply With Quote
 
marss
Guest
Posts: n/a
 
      02-13-2007

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;";

 
Reply With Quote
 
Andrew Poulos
Guest
Posts: n/a
 
      02-13-2007
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
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      02-13-2007
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/
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      02-14-2007
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.
 
Reply With Quote
 
Dr J R Stockton
Guest
Posts: n/a
 
      02-15-2007
In comp.lang.javascript message <>,
Tue, 13 Feb 2007 18:48:13, Randy Webb <> posted:
>
>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.zip> Timo Salmi's Turbo Pascal FAQ.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add </textarea> within <textarea> tags? frank.moens@gmail.com Javascript 1 07-04-2007 04:00 PM
Textarea Inside of a textarea wperry1@gmail.com ASP General 6 02-05-2006 08:00 AM
HTML Text in a textarea tag Ed Anady ASP .Net 5 01-04-2006 08:25 PM
HOW DO I LOAD AND DISPLAY FORMATTED HTML IN TEXTAREA Richard Javascript 5 10-17-2003 09:33 AM
Removing carriage returns from <textarea></textarea> input Augustus ASP General 1 09-10-2003 04:55 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57