admin管理员组

文章数量:1287593

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. direct before I enter one number in the field. How can I build that ?

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. direct before I enter one number in the field. How can I build that ?

Share Improve this question asked Jun 22, 2013 at 7:03 NoonNoon 1,2116 gold badges21 silver badges38 bronze badges 1
  • Something like this? – MasterAM Commented Jun 22, 2013 at 11:49
Add a ment  | 

2 Answers 2

Reset to default 5

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
            });
        }
    }
}]

本文标签: javascriptExtjs Form Validation before SubmitStack Overflow