Do you know the Ext.form-extension TextFieldRemoteVal? If not pleace look here first: http://www.extjs.com/forum/showthread.php?t=4807

I have a formular to edit a user.
The field "username" is an instance of the class "Ext.form.TextFieldRemoteVal"

To create the submit-button I've used the following code:
Code:
{
		text: "submit",
		handler: function() {
			if(user_edit_form.getForm().isValid()) {
				user_edit_form.getForm().submit();
			}
		}
	}
If I click on this button he doesn't wait for the result of the "username"-validation because it's made by AJAX ...
And even if this request returns an false returnValue - you can submit this form ...

Now I'm searching for a solution in one of the following ways:

  1. check if ALL ajax-confirmation has been submitted
  2. check if this specific ajax-confirmation has been submitted (here I have to know how often I want to use this field - not good for dynamic forms)
  3. I change the isValid() function of the class "TextFieldRemoteVal" - but I don't know how
  4. the fastest and (in my eyes) a quick-and-dirty-solution change the submit-handler so you check the username and if this succeeds - you submit the form ... (this can't work with dynamic forms or a form with "standardSubmit: true" !!!)


If anyone has an suitable solution (excepted my solution-way 4) - please write as fast as possible

Here's my full code example:
Code:
var user_edit_form = new Ext.FormPanel({
	labelWidth: 160, // label settings here cascade unless overridden
	labelAlign: 'left',
	id: 'user-edit-form',
	frame: true,
	title: 'Edit your user',
	bodyStyle: 'padding:5px 25px 0 5px',
	defaults: {
		anchor: '100%',
		selectOnFocus: true,
		msgTarget: 'side'
	},
	defaultType: 'textfield',
	
	// use the standardSubmit
	standardSubmit: true,
	
	items: [
	Ext.form.TextFieldRemoteVal({
		fieldLabel: 'loginname',
		invalidText: 'This loginname still exists in the system',
		name: 'useredit[loginname]',
		value: data.loginname,
		allowBlank: false,
		id: 'loginname',
		
		remoteValidation: 'onBlur',
		urlRemoteVal: '?ajax=check_loginname',
		method: 'POST',
		timeout: 20
	}, {
		fieldLabel: 'change your password',
		name: 'useredit[password]',
		value: data.password,
		id: 'password',
		maxLength: 255
	}, {
		fieldLabel: 'firstname',
		name: 'useredit[firstname]',
		value: data.firstname,
		allowBlank: false,
		maxLength: 255
	}, {
		fieldLabel: 'lastname',
		name: 'useredit[lastname]',
		value: data.lastname,
		allowBlank: false,
		maxLength: 255
	}],
	
	buttons: [{
		text: "submit",
		handler: function() {
			if(user_edit_form.getForm().isValid()) {
				user_edit_form.getForm().submit();
			}
		}
	}]
});