user5 4 năm trước cách đây
mục cha
commit
aad4832035
1 tập tin đã thay đổi với 8 bổ sung0 xóa
  1. 8 0
      src/main/webapp/static/utilJs/custom.js

+ 8 - 0
src/main/webapp/static/utilJs/custom.js

@@ -0,0 +1,8 @@
+
+function wirteNum(obj){
+    obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
+    obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字
+    obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个, 清除多余的
+    obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
+    obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数
+}