Textarea and valid HTML

Discussion in 'Javascript' started by Andrew Poulos, Feb 13, 2007.

  1. 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
    Andrew Poulos, Feb 13, 2007
    #1
    1. Advertising

  2. Andrew Poulos

    Randy Webb Guest

    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/
    Randy Webb, Feb 13, 2007
    #2
    1. Advertising

  3. 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
    Andrew Poulos, Feb 13, 2007
    #3
  4. Andrew Poulos

    Ian Collins Guest

    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.
    Ian Collins, Feb 13, 2007
    #4
  5. Andrew Poulos

    marss Guest

    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;";
    marss, Feb 13, 2007
    #5
  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
    Andrew Poulos, Feb 13, 2007
    #6
  7. Andrew Poulos

    Randy Webb Guest

    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/
    Randy Webb, Feb 13, 2007
    #7
  8. Andrew Poulos

    Ian Collins Guest

    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.
    Ian Collins, Feb 14, 2007
    #8
  9. 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.
    Dr J R Stockton, Feb 15, 2007
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    452
    Danana
    Dec 14, 2005
  2. Augustus
    Replies:
    1
    Views:
    338
    Ken Schaefer
    Sep 10, 2003
  3. Textarea Inside of a textarea

    , Feb 4, 2006, in forum: ASP General
    Replies:
    6
    Views:
    315
    Anthony Jones
    Feb 5, 2006
  4. Richard
    Replies:
    5
    Views:
    253
    Richard
    Oct 17, 2003
  5. Replies:
    1
    Views:
    297
    Bart Van der Donck
    Jul 4, 2007
Loading...

Share This Page