PDA

View Full Version : Disable TextField validation



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?

Wulf
12 Jul 2007, 2:03 PM
I think I have a similar request. I want to create a validation which basically reads "if checkbox Y is checked, then input field X is required"...

The problem is that if I use the 'validator' property on the field, it is only executed if the field contains a value (submitting the form or tabbing out of the field does not trigger the validation function).

allowBlank property isn't sufficint, of course, because it always validates, not just when the checkbox is checked...

electronicpeter
25 May 2008, 4:15 AM
How did you solve the problem to force a validation even of blank (e.g. empty) fields ?