Remove euro and money format with jQuery

I already know how to get the value from the label, the problem is that it shows something like

€123,453.28

I need to remove eurosign and commas in order to make a calculation.

Do not delete the decimal point, of course

$(document).ready(function () {
            $("#TxtVatExcluded").keypress(function () {
                var invoicedAmmount = $("#MainContent_VehicleInformationControl_LblInvoicePriceValue").text();
                alert(invoicedAmmount);
                if (invoicedAmmount > 0) {
                    var ammountWithoutVat = $("#TxtVatExcluded").val();
                    var result = (ammountWithoutVat / invoicedAmmount) * 100;
                    $("#OutputLabel").html(result + " %");
                }
            });
        });
+3
source share
1 answer
"€123,453.28".replace(/[^\d.]/g,"") // Replace every non digit char or dot char
                                    // With an empty string.

Live demo

So in your code:

var ammountWithoutVat = $("#TxtVatExcluded").val().replace(/[^\d.]/g,"");
var result = (pareseFloat(ammountWithoutVat, 10) / invoicedAmmount) * 100;
+6
source

All Articles