$(function(){ $(".decimal").on("blur",function(money){ var discount = $(this).val(); var total; if(discount<=0){ alert("商品价格不能小于0!") }else if(discount!==''&&!isNaN(discount)){ total = parseFloat(discount); total = total.toFixed(2) + ""; var re=/(\d{1,3})(?=(\d{3})+(?:$|\.))/g; var n=total.replace(re,"$1,"); return $(this).val(n); }else{ alert("请输入正确的价格!"); return false; } });
判断输入为正数并且增加千分符
最新推荐文章于 2021-09-01 20:31:17 发布