I already know how to get a value from a label, the problem is that its showing something like
€123,453.28
I need to remove the eurosign and the mas to be able to make a calculation.
Not remove 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 + " %");
}
});
});
I already know how to get a value from a label, the problem is that its showing something like
€123,453.28
I need to remove the eurosign and the mas to be able to make a calculation.
Not remove 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 + " %");
}
});
});
Share
Improve this question
edited May 16, 2012 at 12:59
gdoron
150k59 gold badges302 silver badges371 bronze badges
asked May 16, 2012 at 12:02
Luis ValenciaLuis Valencia
34.1k99 gold badges311 silver badges532 bronze badges
1
- What was the value, and what do you want the output to be? – gdoron Commented May 16, 2012 at 12:13
1 Answer
Reset to default 6"€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;