PDA

View Full Version : Form client-side validation



HartlepoolLad
5 Jun 2007, 5:12 AM
I have a form with a disabled Submit button. I want to enable the Submit button when the client-side validation validates that all fields are correctly entered... how do I do this? I have looked at examples, searched with Google, looked at the source and still haven't got a clue... :}

Any help would be appreciated :)

tryanDLS
5 Jun 2007, 7:08 AM
Add handlers to your field for the valid and invalid events.

HartlepoolLad
6 Jun 2007, 5:50 AM
"add handlers to your field"

I have more than one field... How do I go about doing this for multiple fields?

tryanDLS
6 Jun 2007, 7:41 AM
Each field can add listeners for it's events


var userName = new Ext.form.TextField({
id: 'userName',
minLength:3, allowBlank:false, blankText:'User Name is required',
listeners: {
'valid': this.onFormValid,
'invalid': this.onFormInvalid,
scope:this
}
});
userName.applyTo('userName');


You can add this to each field, then enable/disable the button in the handlers

HartlepoolLad
8 Jun 2007, 7:15 AM
Ah, okay, thanks :-)