Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 348
Noon Avatar asked Aug 04 '26 12:08

Noon


2 Answers

Try this:

onFormSubmit: function(btn, event) {
        var me        = this,
        form      = btn.up('form').getForm();
        if(form.isValid()) {
            //submit form
        }
        else alert('Invalid form');
    }
like image 191
Aminesrine Avatar answered Aug 06 '26 03:08

Aminesrine


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
            });
        }
    }
}]
like image 45
Shahin Khalifa Avatar answered Aug 06 '26 03:08

Shahin Khalifa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!