Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Sencha触摸-在NumberField上添加按键事件_Javascript_Extjs_Sencha Touch 2.3 - Fatal编程技术网

Javascript Sencha触摸-在NumberField上添加按键事件

Javascript Sencha触摸-在NumberField上添加按键事件,javascript,extjs,sencha-touch-2.3,Javascript,Extjs,Sencha Touch 2.3,几天来,我一直把头撞在墙上,试图在Sencha Touch文本字段上触发按键或按键事件 我正在努力完成两件事: 1) 将最大长度限制为3和5 2) 确保用户只输入数字(无字母或特殊字符) 是否无法使用Javascript附加这些事件?我正在使用Sencha 2.3.1 更新:我尝试过使用numberfield,也尝试过使用maxLength…这两种方法都不管用 var numberfield = { xtype: 'numberfield', va

几天来,我一直把头撞在墙上,试图在Sencha Touch文本字段上触发按键或按键事件

我正在努力完成两件事: 1) 将最大长度限制为3和5 2) 确保用户只输入数字(无字母或特殊字符)

是否无法使用Javascript附加这些事件?我正在使用Sencha 2.3.1

更新:我尝试过使用numberfield,也尝试过使用maxLength…这两种方法都不管用

   var numberfield = 
    {
        xtype: 'numberfield',
        value: textValue,
        readOnly: true,
        cls: 'opBuyoffPartialCell',
        inputCls: 'opBuyoffCenterText',
        maxLength: 3,
        enforceMaxLength: 3
    };

正如@MonicaOlejniczak所写的,使用

如果您不想使用numberfield,至少可以查看一下它的代码并找到Sencha使用的代码

this.getComponent().input.dom.setAttribute("type", "number");
确保用户只能输入数字。这样,代码允许的“数字”
,,
,也将得到处理


为了确保
maxLength
,sencha已经有了一个在numberfield和textfield上都可用的组件。

为什么不能使用一个组件而不是一个maxLength为3的textfield?遗憾的是,使用numberfield并不能阻止用户输入字母。此外,我还尝试使用maxLength,但它似乎对允许的条目数没有任何影响。我已经在上面粘贴了我的更新代码。