HOW TO VALIDATE FROM IN EXTJS.

Allen Scott

Total Post:46

Points:324
Posted by  Allen Scott
Sencha 
 901  View(s)
Ratings:
Rate this:
Hi Buddy

I want to know that how to validate from in extjs.
Please help me i would really appreciate your help.

Thanks
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: How to validate from in extjs.

    here i am going to validate form please see below code.

    Ext.define('MyApp.view.UserForm', {
        extend: 'Ext.window.Window',
        xtype: 'UserForm',
        modal: true,
        layout: 'fit',
        height: 300,
        width: 400,
        title: 'UserForm',
        items: [
    		{
    		    xtype: 'form',
    		    bodyPadding: 5,
    		    items: [
    				{
    				    xtype: 'fieldset',
    				    title: 'User Info',
    				    defaults: {
    				        xtype: 'textfield',
    				        labelWidth: 100,
    				        width: 300
    				    },
    				    items: [
                            {
                                name: 'UserId',
                                hidden: true
                            },
    						{
    						    fieldLabel: 'Name',
    						    name: 'UserName',
    						    sortable: true,
    						    allowBlank: false,
    						    msgTarget: 'side'
    						},
    						{
    						    fieldLabel: 'Email',
    						    sortable: false,
    						    name: 'UserEmail',
    						    allowBlank: false,
    						    msgTarget: 'side'
    						},
    					    {
    					        fieldLabel: 'Phone',
    					        sortable: false,
    					        name: 'PhoneNumber',
    					        allowBlank: false,
    					            msgTarget: 'side'
    
    					    },
    						{
    						    fieldLabel: 'Address',
    						    sortable: false,
    						    name: 'Address',
    						    allowBlank: false,
    						    msgTarget: 'side'
    						},
    					    {
    					        fieldLabel: 'Password',
    					        name: 'Password',
    					        sortable: false,
    					        allowBlank: false,
    					        msgTarget: 'side'
    					    }
    				    ]
    				}
    		    ],
    		    buttons: [
    				{
    				    text: 'Save',
    				    action: 'saveUser'
    				}
    		    ]
    		}
        ]
    });
    onSaveUserClick: function (button) {
            var self = this;
            var form = button.up('form');
            if (form.isValid()) {
    
            }
            else {
                Ext.Msg.alert('Status', 'Please fill vailid data !', function (btn, text) { });
                return;
            }
    
        }





    Thanks.

      Modified On Oct-05-2016 06:38:28 AM
  1. Hubert Jason

    Post:6

    Points:42
    Re: How to validate from in extjs.

    Great descriptive answer with valid result 

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!