Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
New Contributor
Orber
Posts: 2
Registered: ‎01-02-2013
My Carrier: Rogers

TextField validation

What's the canonical way to validate the contents of a TextField as the user types? For example in one field I want the user to be allowed to enter integer values from 0 to 99. In another text field only valid decimal values from -10.0 to +10.0. So I want to prevent the user from entering invalid characters, and also in the correct  ranges.

 

Please use plain text.
Developer
peter9477
Posts: 5,634
Registered: ‎12-08-2010
My Carrier: none

Re: TextField validation

I'm not sure there's anything "canonical" yet and, since there's no built-in support for filtering like that, your only option appears to be hooking into onTextChanging and attempting to modify the field on-the-fly (or possibly the event can be cancelled when appropriate?).

Peter Hansen -- (PlayBook and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
dishooom
Posts: 103
Registered: ‎12-31-2012
My Carrier: Verizon

Re: TextField validation

Even i feel the same... I had been looking around for something similar for a while and ended up using the onTextChanging event.

Please use plain text.
Developer
Ebscer
Posts: 733
Registered: ‎08-31-2009
My Carrier: Verizon

Re: TextField validation

Please use plain text.
New Contributor
Orber
Posts: 2
Registered: ‎01-02-2013
My Carrier: Rogers

Re: TextField validation

I had tried validating the text using onTextChanging, but what I see happening is when the user enters an invalids character it temporarily appears on screen before I remover it which is undesired. Any way to hook in earlier Like on key press?

Please use plain text.