I have a field in my weblog where a price can be entered on my site which is run with EE 1.7.1. In the template, I have a javascript code that adds a comma and a dollar sign. The problem is that in the latest weblog entries, it is sending the entry field to the template wrapped in paragraph tags. The tags don't show up when I look at the weblog itself, but when I inspect where it should be on the page, the source code shows the tags.

I have tried adding script to remove the tags, but it seems like the html tag is crashing the code.

My code, both for removing the tags and for adding the comma and dollar sign is

    function checkP(p){
        if(p.substring(0,3) == "<p>")
            p = p.substring(3,s.length-4);
        return p;

    function stripTags(p){
        var StrippedString = p.replace(/(<([^>]+)>)/ig,"");
        return StrippedString;

    function addComma(amount){
        if(typeof amount == "string"){
            var a = checkP(amount);
            var a = amount.toString();

        if(a.length > 3){
            var x = a.substring(0,a.length-3);
            var y = a.substring(a.length-3, a.length);
            var b = x + "," + y;

My code that is controlling the price is

    <div id="inv_price">
        {if cf_inv_msrp!=""}MSRP: <b>$<script>addComma(stripTags({cf_inv_msrp}));</script></b>
        {if:elseif cf_inv_price !="" AND cf_inv_price!="0"}Price: <b>$<script>addComma({cf_inv_price});</script></b>
        {if:else}<b>Call for Price</b>{/if}

When I add an alert to addComma, it never gets called which leaves me to believe that the tags are messing up the script's call.

The code works for all of the other entries, and I've tried removing the price and added it again. For an example of what the script should output, you can look at this site.

  • 1
    Sounds like the field format has changed in your latest entries. Sounds like you want the format to be "none" but you have "xhtml". Also, you have the StripTags() call nested inside your addComma() call. I haven't seen that technique before, do you know it to be valid?
    – AllInOne
    Commented Sep 24, 2013 at 18:32
  • The field started out as xhtml formatting and I switched it to none, but apparently the xhtml stuck in the weblogs that I had already created. As for the nested call, it is valid in some languages, but I'm not sure it is in Java. It's now a call from the addComma method, and that specific entry is formatting correctly. Is there a way to automatically switch the other entries to no formatting? I thought that switching the field's formatting would, but it apparently didn't. Commented Sep 24, 2013 at 19:03
  • Yes, when you edit the field group to change the default formatting for the field the save dialog will ask you if want to apply the new format to all the existing entries.
    – AllInOne
    Commented Sep 24, 2013 at 20:31

1 Answer 1


Go to this field via Admin > Channel Administration > Channel Fields > Group > Field and switch the formatting back to XHTML confirm and then back again to none. When switching EE should show a checkbox before confirming asking if you want existing fields to be reformatted. Check this.

Alternatively keep as XHTML in EE and use a plugin to alter the rendered format in template. I created a plugin to do this on Devot-ee. http://devot-ee.com/add-ons/remove-html

  • Thanks. I tried switching the field formatting again like you suggested and it now works. The field doesn't need to have any formatting with it (all it holds is a number), so the plugin isn't needed, but I'll keep it in mind for future use. Commented Sep 25, 2013 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.