Home > DeveloperSection > Forums > How to validate from in extjs.
Allen Scott

Total Post:41

Points:289
Posted on    October-05-2016 6:22 AM

 Sencha Touch Sencha 
Ratings:


 2 Reply(s)
 582  View(s)
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


aditya kumar Patel

Total Post:250

Points:1782
Posted on    October-05-2016 6:29 AM

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

Hubert Jason
Hubert Jason

Total Post:6

Points:42
Posted on    November-07-2016 3:04 AM

Great descriptive answer with valid result 

Don't want to miss updates? Please click the below button!

Follow MindStick