Stephen on Software aka SOS

March 31, 2009

Ext JS – Disabling FormPanel submit if validation fails

Filed under: extjs — sljm @ 3:17 pm

To disable the FormPanel’s submit button if the validation fails (example like allowBlank:false). You will need to set the FormPanel’s monitorValid to true and the submit button’s formBind to true.

var form=new Ext.form.FormPanel{
    monitorValid:true,
    items:[{
      name:"testing",
      xtype:'textfield',
      fieldLabel:'Test',
      allowBlank:false,   //Must be filled in
      value:''            //Set the value so that the validation will trigger
    }],
    buttons:[{
        text:'Submit',
        formBind:true   //If validation fails disable the button
      }
    ]
}

In some cases you might need to set the value of the textfield or combobox explicitly to empty string. If not the validation will not kick in.
Links

Login Form: Disable ’submit’ until username has been input

1 Comment »

  1. Thanks, thats really easy. Now I’m going to investigate how to show validation errors (after server’s validation)

    Comment by Snowcore — November 3, 2009 @ 5:40 pm


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.