1. #1
    Sencha User
    Join Date
    Mar 2014
    Posts
    5
    Answers
    1
    Vote Rating
    1
    IAmAndre is on a distinguished road

      0  

    Default Answered: Can't validate form

    Answered: Can't validate form


    Hi,

    I started learning EXT JS a few days ago, and I'm having issues validating the following form. I'm currently just running tests on the "password" field. The submit button is always active, and when I try to check if the form is valid, well it seems to be considered as such. Here is a snippet of my code :

    Code:
            var form = Ext.create('Ext.form.Panel',{
                    layout: 'vbox',
    //                title: 'Login',
                    width: 300,
                    height: 100,
                    defaults: {
                        labelStyle: 'padding:7 0 0 25;',
                    },
                    items: [{
                        xtype: 'field',
                        name: 'Username',
                        fieldLabel: 'Username',
                        value: 'Your Username',
                        fieldStyle: 'font-style: italic; margin-top: 7;',
    //                    vtype: 'alpha',
                        listeners: {
                            focus: function(){
                                if(this.value == 'Your Username'){
                                    this.setValue('');
                                    this.setFieldStyle('font-style: normal;');
                                }
                            },
                            blur: function(){
                                if(this.value == ''){
                                    this.setFieldStyle('font-style: italic;');
                                    this.setValue('Your Username');
                                }
                            }
                        },
    /*                    validate: function(value){
                            var valid = (value.length>2);
    alert(value);
                            return valid? true : 'The username must have at least 3 characters';
                        }*/
                    },
                    {
                        xtype: 'text',
                        value: 'The username must have at least 3 characters',
                        style: 'font-color:red;'
                    },
                    {
                        xtype: 'field',
                        fieldLabel: 'Password',
                        name: 'Password',
                        value: '',
    //                    inputType: 'password',
    //                    allowBlank: false,
                        minLength:5,
    /*                    validator : function(){
    alert('ttt');
                            return false;
                        },
                        validateOnChange: true*/
                        listeners:{
                            focus : function(){
                                alert(this.isValid());
                            }
                        }
                    }],
                    buttons: [{
                        text: 'Submit',
                        margin: '0 100 0 0',
                        formBind: true,
    //                    disabled: true,
                        handler: function(){
                            alert('submitted');
                        }
                    }]
                });
    I don't know what I'm missing.
    Thanks in advance for your help.

  2. So after one and a half hour of debugging, I found that the issue was just the xtype : it should be set to "textfield" instead of "field".

  3. #2
    Sencha User
    Join Date
    Mar 2014
    Posts
    5
    Answers
    1
    Vote Rating
    1
    IAmAndre is on a distinguished road

      1  

    Default


    So after one and a half hour of debugging, I found that the issue was just the xtype : it should be set to "textfield" instead of "field".

  4. #3
    Sencha - Support Team
    Join Date
    Feb 2013
    Location
    California
    Posts
    2,466
    Answers
    91
    Vote Rating
    52
    Gary Schlosberg has a spectacular aura about Gary Schlosberg has a spectacular aura about Gary Schlosberg has a spectacular aura about

      0  

    Default


    Glad you figured it out, and thanks for posting a followup for the community.
    Are you a Sencha products veteran who has wondered what it might be like to work at Sencha? If so, please reach out to our recruiting manager: sheryl@sencha.com

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar