javascriptjquery-ui-spinner

Use jquery UI to format input but get raw values for calculation


I have a calculator with various number inputs in different formats (currency, percent, etc.).

I'd like the inputs to be formatted when typing to make it easier to use the calculator.

So far I've tried using jquery UI for the formatting. And while it works in the front-end, I can't use the values that returned for calculation in the background, as they are formatted.

<input class="form-control-cur" id="price" value=300000 min=0>

And

$(".form-control-cur").spinner({
 min: 0,
 numberFormat: "C",
 culture: "de-DE",
 step: 100
});

When I try to use the value:

var price = (document.getElementById("price").value);

The value is formatted as 300.000,00 €

What do I need to do in order to get the value "300000" instead of "300.000,00 €"?


Solution

  • Try with

    $( ".form-control-cur" ).spinner("value")

    to get the internal value