regex - Ext JS – 如果验证失败则禁用 FormPanel 提交
问题描述
我无法禁用表单验证失败的按钮。我想使用 regex:/^[0-9]+(,[0-9]+)*$/
进行文本区域验证。我想禁用activatebutton
.
我尝试formBind
并监控验证仍然无法正常工作。
这是代码:
items: [{
xtype: 'container',
layout: {
type: 'column'
},
items: [{
columnWidth: .75,
layout: "form",
monitorValid: true,
items: {
fieldLabel: 'Please Enter Activation Id',
name: 'Activate',
xtype: 'textarea',
msgTarget: 'under',
growMax: 200,
allowBlank: false,
blankText: "Please Enter Comma separated AssetIds",
regex: /^[0-9]+(,[0-9]+)*$/,
anchor: '100%'
}
}, {
columnWidth: .25,
items: {
xtype: 'button',
name: 'button',
id: 'activatebutton',
width: 100,
text: 'Set for auto-activation',
formBind: true,
listeners: {
click: function () {
shared.Notifier.success('The requ ');
this.seForActivation();
},
scope: this
}
}
}]
}]
解决方案
为了formBind
工作,你需要有一个Ext.form.Panel
. 表单面板将处理表单字段的检查,并formBind
在整个表单有效时调用。
以下代码将处理formBind
,另请参阅工作 Fiddle和Ext.form.Panel 文档。
{
xtype: 'form',
layout: 'column',
items: [{
columnWidth: .75,
layout: "form",
monitorValid: true,
items: {
fieldLabel: 'Please Enter Activation Id',
name: 'Activate',
xtype: 'textarea',
msgTarget: 'under',
growMax: 200,
allowBlank: false,
blankText: "Please Enter Comma separated AssetIds",
regex: /^[0-9]+(,[0-9]+)*$/,
anchor: '100%'
}
}, {
columnWidth: .25,
items: {
xtype: 'button',
name: 'button',
id: 'activatebutton',
width: 100,
text: 'Set for auto-activation',
formBind: true,
listeners: {
click: function () {
shared.Notifier.success('The requ ');
this.seForActivation();
},
scope: this
}
}
}]
推荐阅读
- python - np.linalg.eigh() 的 Numpy 分段错误
- jmeter - 无法在 Apache JMeter 1.6 中打开插件管理器
- java - Java + Visual Studio 资源文件夹,以便我可以执行 getResourceAsStream(this.FILE_NAME)
- java - 为什么服务器和客户端不能一起启动?
- python - 根据特定列的值计数添加/删除行
- path - Python 无法识别我的 PATH 配置
- sql - 来自单一来源的父子关系
- typescript - 如何确保保留元组元素标签?
- docker - 如何创建一个标签,其值仅在 RUN 命令后才知道
- python - 为什么 torch.utils.save_image 会覆盖我文件夹中保存的图像?