Javascript 为什么即使vtype的电子邮件验证失败,提交按钮仍在extjs中工作?
下面是一个带有邮箱的窗口面板的extjs代码,我使用vtype:email检查验证。该框显示无效电子邮件的错误,但“提交”按钮仍然有效。当用户单击按钮时,如何抛出无效电子邮件错误Javascript 为什么即使vtype的电子邮件验证失败,提交按钮仍在extjs中工作?,javascript,extjs,Javascript,Extjs,下面是一个带有邮箱的窗口面板的extjs代码,我使用vtype:email检查验证。该框显示无效电子邮件的错误,但“提交”按钮仍然有效。当用户单击按钮时,如何抛出无效电子邮件错误 { vtype:'email', name: 'email', fieldLabel: 'Email', allowBlank:false, id: 'inviteEmail' },{ xtype: 'button', text: 'Send',
{
vtype:'email',
name: 'email',
fieldLabel: 'Email',
allowBlank:false,
id: 'inviteEmail'
},{
xtype: 'button',
text: 'Send',
id: 'invitebuttonid',
handler: function(btn){
var email = Ext.getCmp('inviteEmail').getValue();
var box = Ext.MessageBox.wait('Sending The Invitation..', 'Inviting User')
Ext.Ajax.request({
url: 'url',
params:{
email: email
},
timeout: 300000,
method: 'POST',
success: function(response, opts){
var result = Ext.decode(response.responseText);
if (result.success === true) {
Ext.example.msg('Success', result.message);
box.hide();
}
else {
Ext.Msg.alert('Failed', result.message);
}
},
failure: function(response, opts){
var result = Ext.decode(response.responseText);
Ext.Msg.alert('Failed');
}
});
}
提交前请检查form.isValid()。您可以通过获取值并自己发出Ajax请求来绕过验证
试一试
要根据表单状态自动激活或停用按钮,您需要添加配置
formBind:true
{
xtype: 'button',
text: 'Send',
id: 'invitebuttonid',
formBind: true,
...
}
{
xtype: 'button',
text: 'Send',
id: 'invitebuttonid',
formBind: true,
...
}