ext numberfield添加金额输入效果
来源:互联网 发布:linux 迅雷 编辑:程序博客网 时间:2024/05/21 07:53
if (Ext.form.NumberField) { Ext.apply(Ext.form.NumberField.prototype,{ decimalPrecision: 2, // allowNegative :false, allowDecimals: true // allowBlank : false, cls: 'numReadOnly' // private, FormatComma: true // private, initEvents: function () { Ext.form.NumberField.superclass.initEvents.call(this); var allowed = this.baseChars + ''; if (this.allowDecimals) { allowed += this.decimalSeparator; } if (this.FormatComma) { allowed += ","; } if (this.allowNegative) { allowed += "-"; } this.stripCharsRe = new RegExp('[^' + allowed + ']', 'gi'); var keyPress = function (e) { var k = e.getKey(); if (!Ext.isIE&& (e.isSpecialKey()|| k == e.BACKSPACE || k == e.DELETE)) { return; } var c = e.getCharCode(); if (allowed.indexOf(String.fromCharCode(c)) === -1) { e.stopEvent(); } }; this.el.on("keypress", keyPress, this); }, // private validateValue: function (value) { var tmpvalue = this.removeCommas(String(value)); if (!Ext.form.NumberField.superclass.validateValue.call(this, tmpvalue)) { return false; }// if (!Ext.form.NumberField.superclass.validateValue//.call(this, value)) {// return false;// } if (value.length < 1) { // if it's blank // and textfield // didn't flag // it then it's // valid return true; } if (this.FormatComma) { value = this.removeCommas(String(value)); } value = String(value).replace(this.decimalSeparator, "."); if (isNaN(value)) { this.markInvalid(String.format(this.nanText, value)); return false; } var num = this.parseValue(value); if (num < this.minValue) { this.markInvalid(String.format(this.minText,this.minValue)); return false; } if (num > this.maxValue) { this.markInvalid(String.format(this.maxText,this.maxValue)); return false; } return true; }, fixPrecision: function (value) { var nan = isNaN(value); if (!this.allowDecimals|| this.decimalPrecision == -1|| nan || !value) { return nan ? '' : value; } return parseFloat(parseFloat(value).toFixed(this.decimalPrecision)); }, setValue: function (v) { v = typeof v == 'number' ? v : (String(this.removeCommas(v)).replace(this.decimalSeparator, ".")); v = isNaN(v) ? '' : String(v).replace(".", this.decimalSeparator); if (String(v).length > 0) v = parseFloat(v).toFixed(this.decimalPrecision); // if(this.FormatComma) // v=this.formatCommaStyle(v); Ext.form.NumberField.superclass.setValue.call(this, v); if (this.FormatComma&& String(v).length > 0) { v = this.addCommas(v); Ext.form.NumberField.superclass.setRawValue.call(this, v); } }, parseValue: function (value) { if (this.FormatComma) value = this.removeCommas(String(value)); value = parseFloat(String(value).replace(this.decimalSeparator,".")); return isNaN(value) ? '' : value; }, beforeBlur: function () { var v = this.parseValue(this.getRawValue()); if (String(v).trim().length > 0) { this.setValue(this.fixPrecision(v)); } }, addCommas: function (nStr) { nStr += ''; if (nStr.length == 0) return ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx,'$1' + ',' + '$2'); } return x1 + x2; }, removeCommas: function (nStr) { nStr = nStr + ''; var r = /(\,)/; while (r.test(nStr)) { nStr = nStr.replace(r, ''); } return nStr; }}); }
这个是网上搜到了,稍微修改了下,原先的有个问题,就是在进行form验证的时候,无法通过,总是先试试不是有效值,这个就没有问题了
- ext numberfield添加金额输入效果
- EXT.NET NumberField 数字输入框
- Ext.net 数字输入框NumberField属性设置
- Ext.form.NumberField使用
- EXT实现邮件地址输入效果
- 关于Ext.form.NumberField中输入一个超大数字,失去焦点后变成另一个数字的bug的处理
- 选择添加输入效果
- Ext_数字输入框_Ext.form.NumberField
- 【Android】对EditText输入金额添加限制及监听
- Ext.widgets-form(下)ComboBox,TimeField,DateField,TriggerField,TextArea,NumberField
- Ext.widgets-form(下)ComboBox,TimeField,DateField,TriggerField,TextArea,NumberField
- Ext.widgets-form(下)ComboBox,TimeField,DateField,TriggerField,TextArea,NumberField
- Ext.widgets-form(下)ComboBox,TimeField,DateField,TriggerField,TextArea,NumberField
- Ext.Net 1.x_Ext.Net.NumberField的属性
- EXT NumberField\TextField\ComboBox的fieldLabel动态修改
- EXT textfield 输入框添加键盘监听事件
- 在Ext的GridPanel中添加鼠标悬停的效果
- Ext 的Ajax 请求,添加mask 等待效果。
- Android Intent Filter简单使用
- 2.3版本修改录像编码格式
- 高斯取整函数与Beatty定理
- 文件的多线程下载
- .Net C#语法 构造函数中this和base
- ext numberfield添加金额输入效果
- Debian使用入门(1) apt-cache
- 字符串匹配算法 Boyer-Moore
- POJ 2226 Muddy Fields 匈牙利算法/最小点覆盖
- 网站建设-如何才能设计好一个网站
- Linux 下值得使用的 5 个屏幕录像软件
- 类比推理每日练习及精解20110830
- GCC 编译命令笔记
- 《九局下半》