为什么提交按钮在 extjs 中仍然有效,即使使用 vtype 的电子邮件验证失败
Why submit button still works in extjs even if email validation with vtype is failed?
下面是一个带有邮箱的窗口面板的extjs代码,我使用vtype:email来检查验证。该框显示无效电子邮件的错误,但提交按钮仍然有效。当用户单击按钮时,如何抛出无效的电子邮件错误?
{
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');
}
});
}
要根据
表单状态自动激活或停用按钮,您需要添加配置formBind: true
。
{
xtype: 'button',
text: 'Send',
id: 'invitebuttonid',
formBind: true,
...
}
在提交之前检查 form.isValid()。通过获取值并自行发出 Ajax 请求来绕过验证。
尝试
var form = this.up('form');
If (form.isValid()) {
// your handler code
相关文章:
- 当json解析空响应时,Whatwg-Fetch失败,我该如何防止它
- JsFiddle在分叉后描述失败
- 为什么不'当单元测试出现解析错误时,我的因果报应测试会失败
- 当一些承诺失败时,如何继续使用$q.all()
- 失败:等待Protractor与页面同步时出错:“”;在窗口上找不到角度”;
- 在Jquery中单击传播失败
- 网页上失败的javascript会导致所有其他脚本失败
- 带有对象解析的响应javascript ajax失败
- 一台特定计算机的Ajax请求数据未定义/失败
- Nodejs服务器:加载资源失败:服务器的响应状态为404(未找到)
- jQuery.getJSON失败,语法错误
- ng disabled在放入多个表达式时失败
- Jasmine单元测试在监视服务方法时失败
- jQuery分页下一页和上一页按钮在点击零或超过最后一页后失败
- 在iframe的情况下,jQuery html()将失败
- 在我的情况下,使用带有变量失败的 jquery 选择器
- CSS中的转换似乎失败了,原因是什么
- 在数组中插入对象失败
- Backbone fetch中的Ajax在fetch调用退出后完成,因此fetch调用中没有成功/失败事件
- 为什么提交按钮在 extjs 中仍然有效,即使使用 vtype 的电子邮件验证失败