Ext.MessageBox提示的正则表达式
Regular Expression for prompt of Ext.MessageBox
我提示用户填写字母和数字的组合。
代码如下:
Ext.Msg.show({
title : 'you can enter alphabets and number',
msg : 'Your value',
buttons: Ext.Msg.OKCANCEL,
scope : this,
prompt:true
});
虽然它提示填写值,但我想在该字段中添加正则表达式。
我不想添加文本字段或使用 window。
如果可以在提示中添加正则表达式,请帮助。
不幸的是,Ext.Msg
的提示功能并不是为了做这样的事情。
在 NumberField prompt in ExtJS 中,您可以找到 2 个可能的黑客来实现这一目标。但他们是黑客...
我知道你说过你不想使用 window,但你可以通过一个 Window 对象来实现这一点,该对象带有一个表单面板和一个配置了正则表达式的文本字段。
像这样:
Ext.QuickTips.init();
var win = new Ext.Window({
title: 'You can enter alphabets and number',
modal: true,
items : [{
xtype:'form',
itemId: 'myForm',
autoheight:true,
width:300,
padding:5,
border:false,
unstyled:true,
style: 'background-color:#CCD8E7;',
items: [{
xtype: 'textfield',
fieldLabel: 'Your value',
regex: new RegExp('^[a-zA-Z0-9]+$'),
regexText: 'You must enter letters and numbers only',
emptyText: 'Use Letters and Numbers'
}],
bbar: [{
text:'Submit',
handler: function() {
//Form submit here
}
}]
}]
});
win.show();
我提示用户填写字母和数字的组合。
代码如下:
Ext.Msg.show({
title : 'you can enter alphabets and number',
msg : 'Your value',
buttons: Ext.Msg.OKCANCEL,
scope : this,
prompt:true
});
虽然它提示填写值,但我想在该字段中添加正则表达式。
我不想添加文本字段或使用 window。 如果可以在提示中添加正则表达式,请帮助。
不幸的是,Ext.Msg
的提示功能并不是为了做这样的事情。
在 NumberField prompt in ExtJS 中,您可以找到 2 个可能的黑客来实现这一目标。但他们是黑客...
我知道你说过你不想使用 window,但你可以通过一个 Window 对象来实现这一点,该对象带有一个表单面板和一个配置了正则表达式的文本字段。
像这样:
Ext.QuickTips.init();
var win = new Ext.Window({
title: 'You can enter alphabets and number',
modal: true,
items : [{
xtype:'form',
itemId: 'myForm',
autoheight:true,
width:300,
padding:5,
border:false,
unstyled:true,
style: 'background-color:#CCD8E7;',
items: [{
xtype: 'textfield',
fieldLabel: 'Your value',
regex: new RegExp('^[a-zA-Z0-9]+$'),
regexText: 'You must enter letters and numbers only',
emptyText: 'Use Letters and Numbers'
}],
bbar: [{
text:'Submit',
handler: function() {
//Form submit here
}
}]
}]
});
win.show();