European number format in jQuery Calculation Plug-in (v0.4.08)

European number format in jQuery Calculation Plug-in (v0.4.08)

I have used the jQuery Calculation Plug-in (v0.4.08) in a pricecalculator. I all works very fine except for returning numbers with a "." - thousand operator.

In order make the plugin compatible with danish the price format: fx.  1.212,95 kr. I have set the calculation defaults as following.

$.Calculation.setDefaults({
    // a regular expression for detecting European-style formatted numbers
    reNumbers: /(-|-\$)?(\d+(\.\d{3})*(,\d{1,})?|,\d{1,})?/g
    // define a procedure to convert the string number into an actual usable number
    , cleanseNumber: function (v){
        // cleanse the number one more time to remove extra data (like commas and dollar signs)
        // use this for European numbers: v.replace(/[^0-9,\-]/g, "").replace(/,/g, ".")
        return v.replace(/[^0-9,\-]/g, "").replace(/,/g, ".");
    }
})

I need the totals to be rendered with the "." - thousand operator.
Now: 1233 kr.
Should be: 1.233 kr.

How do I format the numbers correctly?

Regards,

Trine





























    • Topic Participants

    • tb