php mysql数字格式输入物有所值

问题描述 投票:0回答:1

我使用数字作为我的钱输入值,所以当我键入数字时

15000 then it should be 15,000
55350 became 55,350

但是当我保存输入时,为什么在我的数据库中存储为

15.00 and 55.00

即时通讯使用decimal(18,2)获取此货币价值

这是我在输入类上的代码

    $(document).ready(function () {
      $(".mny").number(true); 
     }

我错过了什么或我应该转换价值? THA

php jquery
1个回答
0
投票

你这样试试,

$(document).ready(function () {
    var withComma = $('#value').val().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    var replaceDot = withComma.replace(/,/g, ".");
    console.log(withComma , replaceDot);
});
© www.soinside.com 2019 - 2024. All rights reserved.