//录入值实时改变事件;
$(document).on('input propertychange', '#pricejie', function () {
var stmp = "";
var t = $(this).val();
if (t == stmp) return;
var ms = t.replace(/[^\d\.]/g, "").replace(/(\.\d{2}).+$/, "$1").replace(/^0+([1-9])/, "$1").replace(/^0+$/, "0");
var txt = ms.split(".");
while (/\d{4}(,|$)/.test(txt[0]))
txt[0] = txt[0].replace(/(\d)(\d{3}(,|$))/, "$1,$2");
t = stmp = txt[0] + (txt.length > 1 ? "." + txt[1] : "");
$(this).val(t);
});
js 录入值实时监测事件,设置数值文本框不可以输入其他字符。
最新推荐文章于 2024-08-22 17:38:39 发布