0
I have a function that is called here:
$("#valorPrimeiroPedido").focusout(function () {
var valor = $("#valorPrimeiroPedido").val();
calcularValorMercadoria(valor);
});
$("#valorPrimeiroPedido").val()
already brings me the formatted value (ex:R$:1.500,56). When it loses focus it calls the function below, passing the formatted value. There is the error. I cannot calculate the IPI and show in HTML.
function calcularValorMercadoria(valor) {
var _valorPedido = CurrencyFormat(valor);
var _valorPedidoComIPI = _valorPedido * 1.1;
console.log(_valorPedido);
$("#ipi").html("Valor do pedido com IPI: R$ " + CurrencyFormat(_valorPedidoComIPI));
}
Erro: Uncaught ReferenceError: *CurrencyFormat is not defined*.
When I take off the mask CurrencyFormat
, the value returned is: R$ NaN
I’m using some libraries:
<script src="~/Content/modalAjax/jquery-3.3.1.min.js"></script>
<script src="~/Content/modalAjax/bootstrap.min.js"></script>
<script src="~/Scripts/jquery.maskedinput.js"></script>
<script src="~/Areas/Representantes/Script/cliente/cadastro.js"></script>
<script src="~/Areas/Representantes/Script/cliente/abas.js"></script>
<link href="~/Areas/Representantes/Script/cliente/ClienteEstilo.css" rel="stylesheet" />
<script src="~/Content/modalAjax/bootstrapcdn.min.js"></script>
<script src="~/Content/modalAjax/ajaxmodaldeconfirmacaobootbox.min.js"></script>
<script src="https://cdn.rawgit.com/plentz/jquery-maskmoney/master/dist/jquery.maskMoney.min.js"></script>
Summary: I need to take the value in Real format, calculate the IPI and show the calculation also in Real format and then save in format float (in SQL).
You have to use the
replace
to remove theR$
and replace the comma with the point.– Valdeir Psr