jquery限制文本框只能输入金额

 1 $("#batch_diff_percent").keyup(function () {
 2     var reg = $(this).val().match(/d+.?d{0,2}/);
 3     var txt = '';
 4     if (reg != null) {
 5         txt = reg[0];
 6     }
 7     $(this).val(txt);
 8 }).change(function () {
 9     $(this).keypress();
10     var v = $(this).val();
11     if (/.$/.test(v))
12     {
13         $(this).val(v.substr(0, v.length - 1));
14     }
15 });

只能输入金额 小数点保留2位

原文地址:https://www.cnblogs.com/xionggeclub/p/5868645.html