使用 jquery UI 格式化输入但获取原始值进行计算

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

我有一个计算器,可以输入不同格式(货币、百分比等)的各种数字。

我希望在打字时对输入进行格式化,以便更轻松地使用计算器。

到目前为止,我已尝试使用 jquery UI 进行格式化。虽然它在前端工作,但我不能在后台使用返回的值进行计算,因为它们是格式化的。

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

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

当我尝试使用值时:

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

值的格式为 300.000,00 €

我需要做什么才能得到值“300000”而不是“300.000,00 €”?

试试

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

获取内部值