INeedADip
23 Apr 2007, 6:50 PM
How can I tap into the validation function for a form.TextField.
I want to do something like:
var chkPhone = new Ext.form.TextField({
validator : function(){
if(this.value.trim().length == 0 && somethingCustom){return false;}
}
})
Or I would like to set it up with just (allowBlank: true) and turn it on or off in my script.
If they select a particular combobox value I want to validate the phone text field, otherwise I don't want it to validate.
I was going to create it when they change the value in the combo box, but if they change it back I don't want to validate it anymore, so I thought about doing a chkPhone.reset();
But if they select that particular option I want to re-enable the validator making the field required. Any input?
I want to do something like:
var chkPhone = new Ext.form.TextField({
validator : function(){
if(this.value.trim().length == 0 && somethingCustom){return false;}
}
})
Or I would like to set it up with just (allowBlank: true) and turn it on or off in my script.
If they select a particular combobox value I want to validate the phone text field, otherwise I don't want it to validate.
I was going to create it when they change the value in the combo box, but if they change it back I don't want to validate it anymore, so I thought about doing a chkPhone.reset();
But if they select that particular option I want to re-enable the validator making the field required. Any input?