[英]Extjs Form Validation before Submit
I have an Extjs form which it needs some validations like when I enter letters instead of numbers, it should alert me before I submit. 我有一个Extjs表单,它需要一些验证,例如当我输入字母而不是数字时,它应该在提交之前提醒我。 direct before I enter one number in the field. 在我在该字段中输入一个数字之前直接输入。 How can I build that ? 我该如何构建呢?
Try this: 尝试这个:
onFormSubmit: function(btn, event) {
var me = this,
form = btn.up('form').getForm();
if(form.isValid()) {
//submit form
}
else alert('Invalid form');
}
buttons: [{
text: "Continue",
margin: "0 5 10 0",
handler: function () {
var getForm = this.up("form").getForm();
if (getForm.isValid()) {
code her if form is valid
} else {
Ext.MessageBox.show({
title: "ERROR-A1001",
msg: "Please fill the required fields correctly.",
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.WARNING
});
}
}
}]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.