jquery-easyui-jqnumber 

 

这里的options是选项,可以参考下表:

选项名 类型 描述 默认值
min 数字 文本框中可允许的最小值 null
max 数字 文本框中可允许的最大值 null
precision 数字 最高可精确到小数点后几位 0

 

例如:金额输入框 最大值为“99999.99” 精确到两位小数。

<input name="money" />

 

如果是动态的input 加载的时候会有问题。

解决方法:

       动态载入/删除/更新外部 JavaScript/Css 文件

加载动态的input后,更新一下jquery.easyui.min.js文件。就相当于重新加载一次jquery.easyui.min.js文件。

 

 

 

另转一个 JQuery 验证表单只能输入数字 支持火狐

$.fn.numeral = function() {  
            $(this).css("ime-mode", "disabled");  
            this.bind("keypress",function(e) {  
            var code = (e.keyCode ? e.keyCode : e.which);  //兼容火狐 IE   
                if(!$.browser.msie&&(e.keyCode==0x8))  //火狐下 不能使用退格键  
                {  
                     return ;  
                    }  
                    return code >= 48 && code<= 57;  
                 
            });  
            this.bind("blur", function() {  
                if (this.value.lastIndexOf(".") == (this.value.length - 1)) {  
                    this.value = this.value.substr(0, this.value.length - 1);  
                } else if (isNaN(this.value)) {  
                    this.value = "";  
                }  
            });  
            this.bind("paste", function() {  
                var s = clipboardData.getData('text');  
                if (!/\D/.test(s));  
                value = s.replace(/^0*/, '');  
                return false;  
            });  
            this.bind("dragenter", function() {  
                return false;  
            });  
            this.bind("keyup", function() {  
            if (/(^0+)/.test(this.value)) {  
                this.value = this.value.replace(/^0*/, '');  
                }  
            });  
        };  

 

使用方法 $("#txt1").numeral();  

相关文章:

  • 2022-12-23
  • 2021-05-24
  • 2022-12-23
  • 2021-10-28
  • 2021-07-03
  • 2022-02-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案