繁体   English   中英

Sencha Touch-在NumberField上添加KeyDown事件

[英]Sencha Touch - add KeyDown event on NumberField

数天来,我一直在努力地努力使KeyPress或KeyDown事件在Sencha Touch文本字段上触发。

我正在尝试完成两件事:1)将最大长度限制为3和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已经具有maxLength配置 ,该配置在numberfield和textfield上都可用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM