简体   繁体   中英

jQuery/JavaScript: Auto Number Format

Currently, I am using this plugin https://github.com/teamdf/jquery-number to auto-format the number that I entered, but I encountered some problem, when I enter 999999999999999.99 it will round off to 1,000,000,000,000,000.00, I don't need to round off the number that I entered, I only need to format the number using the comma, I need the exact numbers that I entered, how can I do it? is there any way?

here is my current code:

$(".numeric-total").blur(function () {
     var value = $(this).val();

     value = $.number(value.replace(/,/g, ""), 2);
     $(this).prop('value', value);           
});
<script>
    jQuery(document).ready(function () {
        $(".numeric-total").blur(function () {
            var value = $(this).val();
            value = value.replace(".", ",");
            value = $.number(value.replace(/,/g, ""), 2);
            alert(value);
            $(this).prop('value', value);
        });
    });
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM