You might find this interesting: We made a javascript function that trims leading/trailing spaces from field values, but found it did not include the nonbreaking space character (nbsp;) when it appeared.
Before fixing it, our function looked like this:
-------------------------------------
String.prototype.Trim = function() {

return this.replace(/(^\s*)|(\s*$)/g, "");

}
-------------------------------------
After discovering that values that included nbsp; were not getting trimmed, I found the following to be true:

nbsp; = chr(160) = xA0

So have now modified the Trim function to read:

-------------------------------------
String.prototype.Trim = function() {
return this.replace(/(^{\s\xA0#}*)|({\s\xA0#}*$)/g, "");
}
-------------------------------------

(Please note that I used CURLY BRACKETS in the example above, but if you use this, use SQUARE BRACKETS -- they just wouldn't display on this page when I typed them in...)

And it works!! FYI, to clean field values, our javascript code calls it this way:
document.forms[0].myField.value.Trim();
Hope this helps someone,
Susan Henesy

Originally posted as a Categorized Answer.


In reply to Re: how-to strip empty HTML tags like <b> </b> by Anonymous Monk
in thread how-to strip empty HTML tags like &lt;b&gt; &lt;/b&gt; by russmann

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.