jQuery EasyUI 数字框,NumberBox用法

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();