Take the 2-minute tour ×

The extjs numberfield has a maxValue property that works well for the spinner (up/down buttons), but doesn't prevent invalid keyboard input. I want to keep the keyboard input, but I want to force correct values and not have to flag it further down the line.

In the onchange handler, I validate newValue against the maxValue and set it back to maxValue, but then I have to use setValue on the control to update it. This fires another onchange event. There is logic based on the onchange event which now gets fired twice.

I'm probably looking for one of two solutions: - 1: be able to update the control value without firing the onchange event - 2: use some inbuilt numberfield property to force entered values back to the max

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

setRawValue( Object value ) should work with out firing the event, or you can suspend events on the numberfield by

numberfield.suspendEvents( false );//suspend
numberfield.setValue(val); //set value
numberfield.resumeEvents( );//resume events
share|improve this answer
Excellent - I had already tried setRawValue without success, but suspending and resuming events did the trick. –  Savage Dec 22 '11 at 13:01
add comment

Your Answer


