Results 1 to 8 of 8

Thread: validation disable button

  1. #1
    Sencha User
    Join Date
    Aug 2009
    Posts
    122

    Question validation disable button

    Hello!

    Don't know, how to disable a button, when a field of form isn't valid!

    Had tested following:

    Code:
    layout        : 'form',
    monitorValid: true,
    items        : [{...}]
    
    --------------------------
    
    xtype    : 'button',
    formBind: true,
    scope    : this
    It's a bit complicated to explain, because first part is in center region and second on east region of borderlayout! I still haven't found another valuation...

    PS: I also don't find formBind in doc

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    You have to listen for the FormPanel's clientvalidation event, and in the listener, set the Button's disabled state accordingly.

  3. #3
    Sencha User
    Join Date
    Aug 2009
    Posts
    122

    Default

    How to listen?

    I tried following:

    Code:
    Ext.getCmp('baseconfigurationForm').clientvalidation({
        ????
    });
    Am I able to use this? My button now haven't an ID, is this a problem?

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    Event?

  5. #5
    Sencha User
    Join Date
    Aug 2009
    Posts
    122

    Default

    Code:
    Ext.getCmp('baseconfigurationForm').on({'clientvalidation':test, scope:this});
    ???

  6. #6
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    And? Your function test.

    What does it do?

  7. #7
    Sencha User
    Join Date
    Aug 2009
    Posts
    122

    Default

    Thank you for your help animal!

    Here is my solution:
    Code:
    Ext.getCmp(field).addListener('change',function(){
        if(Ext.getCmp(field).isValid()){
            Ext.getCmp(button).setDisabled(false);
        }
        else{
            Ext.getCmp(button).setDisabled(true);
        }
    });
    Maybe it's not the finest, but it work

  8. #8
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    Well, if it's only one field, that's fine.

    If it's the whole form which has to be valid, you need to use the clientvalidation event of the FormPanel.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •