1. #1
    Sencha Premium Member
    Join Date
    Sep 2012
    Posts
    79
    Answers
    4
    Vote Rating
    7
    zz9pa is on a distinguished road

      0  

    Default Answered: setting validator function dynamically...

    Answered: setting validator function dynamically...


    I know I can set a validator function via a 'config' when I create my fields..
    Is there anyway to change the validator *after* the field has been created ?

    In my case - there may be some fields in my forms which are generated by Ext.create(...), and I want to apply the validations to them after they have been created.

  2. Looks like you can just set the validator function any 'ol time. Works in 4.1.3 at least - I suspect it works the same in past versions.

    Code:
    var f = Ext.create('Ext.form.Panel', {
        title: 'Contact Info',
        width: 300,
        bodyPadding: 10,
        renderTo: Ext.getBody(),
        items: [{
            xtype: 'textfield',
            name: 'name',
            fieldLabel: 'Name',
            allowBlank: false  // requires a non-empty value
        }, {
            xtype: 'textfield',
            name: 'email',
            fieldLabel: 'Email Address',
            vtype: 'email'  // requires value to be a valid email address format
        }]
    });
    
    
    f.down('textfield').validator = function (val) {
        console.log(val);
    }

  3. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,913
    Answers
    371
    Vote Rating
    179
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    Looks like you can just set the validator function any 'ol time. Works in 4.1.3 at least - I suspect it works the same in past versions.

    Code:
    var f = Ext.create('Ext.form.Panel', {
        title: 'Contact Info',
        width: 300,
        bodyPadding: 10,
        renderTo: Ext.getBody(),
        items: [{
            xtype: 'textfield',
            name: 'name',
            fieldLabel: 'Name',
            allowBlank: false  // requires a non-empty value
        }, {
            xtype: 'textfield',
            name: 'email',
            fieldLabel: 'Email Address',
            vtype: 'email'  // requires value to be a valid email address format
        }]
    });
    
    
    f.down('textfield').validator = function (val) {
        console.log(val);
    }

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi