javascript - 如何防止大文本字段数字转换为 1e 表示法 -Javascript/EXTJS

标签 javascript extjs

我有一个仅包含输入的文本字段,并且对输入的大小没有设置最大限制。现在,当我输入大数字时,数字会转换为 1e 表示法。 例如:

enter image description here

我使用 EXTJ 作为我的代码库: 代码:

$cls.superclass.constructor.call(this, Ext.apply({
        items: [
            this.section({
                items: [{
                    xtype: 'container',
                    items: [
                        this.limit = new Ext.form.NumberField({
                            cls: "limit-number-field",
                            allowBlank: false,
                            allowNegative: false,
                            allowDecimals: false,
                            width: 150
                        })
                    ]
                }]
            })
        ]
    }, cfg));

这里还有我尝试过的数字的日志 toFixed() enter image description here

他们都给了我相同的o/p。不知道我在这里做错了什么。

如何防止这种情况发生。我希望数字按原样出现在输入字段中。

PS> 我提到了How to avoid scientific notation for large numbers in JavaScript? 但这对我不起作用。 有什么想法吗?

最佳答案

如果您只想要一个允许用户键入一长串数字而无需任何格式的文本字段,您可以使用 maskRe 的文本字段。 。这将允许用户仅键入与掩码中的正则表达式匹配的字符。

Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
items: [{
    xtype: 'textfield',
    fieldLabel: 'Number',
    maskRe: /[0-9]/
}]

});

see fiddle here

关于javascript - 如何防止大文本字段数字转换为 1e 表示法 -Javascript/EXTJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56435815/

相关文章:

Mysql 存储读取 true 或 false 的 bool 值

javascript - 需要调用工具提示上的 Morris.js 单击事件

extjs - 找不到 stbuild

javascript - Extjs MVC文件夹结构无法加载文件

javascript - 弹出窗口显示在页面下方而不是弹出窗口

javascript - ExtJS 4 - 动态更改折线图中的图例颜色

javascript - XMLHttpRequest 响应在 Internet Explorer 中没有 header

javascript - 如何停止浏览器的热键?

javascript - 如何使用 JavaScript 使 "input type text"不可见?

javascript - 在 IE 中测试 console.log 语句