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
babaworks
Posts: 6
Registered: ‎10-23-2012
My Carrier: None

Strange! There is no numeric-only input for TextFieldInputMode?

TextFieldInputMode supports the following numeric input modes but none of them restrict input to just numbers.

PhoneNumber
NumbersAndPunctuation
NumericPassword
Pin

This has got to be an extremely common use-case.  Is there a work around besides filtering input as it's typed?

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

Re: Strange! There is no numeric-only input for TextFieldInputMode?

Not that I don't also miss that option, but note that some might also say they'd like "numbers and decimal place only" or "numbers and plus or minus", and so on.

Also, there's probably ways of using copy/paste to bypass the keyboard restrictions.

I short, I think filtering is probably what's required in any event... The custom keyboards are just a convenience for the user, but perhaps not a mechanism developers should rely on to restrict the input.

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.
New Contributor
babaworks
Posts: 6
Registered: ‎10-23-2012
My Carrier: None

Re: Strange! There is no numeric-only input for TextFieldInputMode?

That could easily be fixed by designing the options to be OR'able together like so:

TextFieldInputMode.Numeric | TextFieldInputMode.Punctionation
TextFieldInputMode.Numeric | TextFieldInputMode.Plus | TextFieldInputMode.Minus
TextFieldInputMode.Numeric | TextFieldInputMode.Decimal
TextFieldInputMode.Numeric | TextFieldInputMode.Password

Please use plain text.
Visitor
denisdagenaisOrleans
Posts: 1
Registered: ‎02-22-2013
My Carrier: Bell Canada

Re: Strange! There is no numeric-only input for TextFieldInputMode?

I hve also tried the nummericandpunctuation and on the latest Z10 release using 1673 (10.0.9.), my app still accepts the full keyboard.

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

Re: Strange! There is no numeric-only input for TextFieldInputMode?

This is true... the NumbersAndPunctuation keyboard doesn't prevent text entry, it just starts off on the numeric version of that as a convenience to the user. Text filtering in some fashion is still required, or a custom data entry keyboard, at least for now.

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
Developer
klz
Posts: 127
Registered: ‎08-24-2011
My Carrier: MTS Ukraine

Re: Strange! There is no numeric-only input for TextFieldInputMode?

I did that using RegExp

 

Here is a JS function:

    function numericOnly (textin) { // allow users to use numbers only
                 
         var m_strOut = new String (textin);
         m_strOut = m_strOut.replace(/[^\d.]/g,'');
         
         return m_strOut;
                             
    } // end numericOnly

 and call once TextChanging signal is emitted:

 

			                onTextChanging: {
			                    text = numericOnly(text)

			                }

 That should work. 

 

 

 

 

Thank you!
----------------------------
BlackBerry 10 Developer is looking for a job!
My Apps: Alchemy Game | Jam! | Traffic Signs: USA
My Blog: http://bb10pro.com
Please use plain text.