View Full Version : [FIXED] Field and setAutoValidate()

18 Jan 2012, 1:25 PM
I am looking at your "Forms Example" from your Explorer Demo and have compiled it and running it locally.


Now, I do the following for the 'age' field

age.addValidator(new MaxNumberValidator<Integer>(99));

I am still able to enter values > 99 and I get no validation message until I leave the field.

Is this an error, or am I not understanding the behavior of setAutoValidate().


I modified SpinnerField (in the same Forms Example) to have 'setAutoValidate(true)', it doesn't prevent me from using the spinner to move the value above or below the expected value. What should be expected?

SpinnerField<Double> spinnerField = new SpinnerField<Double>(new DoublePropertyEditor());

FieldLabel spinLabel = new FieldLabel(spinnerField, "Duration(s)");

What I was hoping was the following

a. the spinner would not spin lower than the min or higher than the max
b. if you enter a value < the min, it would be replaced with the min, if you enter a value > max, it would be replaced with the max.

Now, I can see other behaviors for "b", but I would expect autoValidate to prevent that.

Am I understanding autoValidate for spinners, or am I missing something here as well?


19 Jan 2012, 12:08 AM

the Validator of a Field will be called with the old value until you leave the Field.
See my post Validation bug in TextField (http://www.sencha.com/forum/showthread.php?162541-Validation-bug-in-TextField).

I think this is a bug. At every keyup-Event the Validator will be called with the old value from the cell.

15 Feb 2012, 8:00 AM
Hi schorse,

i can only confirm that wrong behavior. Have just stumbled upon it myself because i need to validate user text input in a grid (I am using a text field).

Always, the initial value is validated, NOT the value changed by the user.

Best Regards,

17 Feb 2012, 2:43 AM
Issue still not fixed in beta 3.

17 Feb 2012, 1:35 PM
Thanks for the update. I'll file a bug for the team to take a look at this and will update this thread with any developments.

Colin Alworth
1 Mar 2012, 6:07 PM
A fix for this issue is available in Beta4, released today. It can be seen working at http://sencha.com/examples-dev/#ExamplePlace:basicbinding on the Symbol field - enter a lower case letter to trigger it.

As an implementation note, if the entered value cannot be parsed as the field's data, the validaters will have to work with a null instance. In many cases, this will mean no validation occurs. Validation errors will show up if the value still cannot be parsed after the user blurs the field.