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.

inside custom component

Native Development

Reply
Developer
Suns33k3r
Posts: 26
Registered: ‎07-22-2012
My Device: Z10
My Carrier: Telstra
Accepted Solution

Text input mode and user input validation

Hey guys, has anybody tried to implement some kind of input validation on BB 10?

According to documentation, we've got TextField which can be assigned one of the variants of TextFieldInputMode: URL, PhoneNumber, NumbersAndPunctuation etc.

There're no examples showing this functionality in action in Cascades examples source code on GitHub.

I've tried almost all the variants from the documentation and haven't notice any changes in pop-up keyboard. It always shows all the characters with special keys so user able to input whatever he or she wants. I presume this is what is called "Default" variant of keyboard. That's not good for me. At least, I want to be able to pass user input through regular expression and raise a warning if something is wrong with provided value. But, it'd be much better off to limit user input by certain variants of keyboard (for ex, only numeric keyboard)

Here is my code:
            TextField {
                id: iValue
                hintText: "Enter your value"
                inputMode: TextFieldInputMode.URL    // change this to whatever you want - no changes
                bottomMargin: 50.0
                textStyle { base: SystemDefaults.TextStyles.BodyText  }

                layoutProperties: StackLayoutProperties {
                    horizontalAlignment: HorizontalAlignment.Fill
                }
        }

Is it possible to show only numeric keyboard and, possibly, use some regexp validation of user input at the moment?

Please use plain text.
Developer
Suns33k3r
Posts: 26
Registered: ‎07-22-2012
My Device: Z10
My Carrier: Telstra

Re: Text input mode and user input validation

Created an issue in Developer Issue Tracker - https://www.blackberry.com/jira/browse/BBTEN-145

Please, vote up if anyone else watches the same result

Please use plain text.
Developer
jheron
Posts: 188
Registered: ‎01-27-2012
My Device: playbook
My Carrier: ...

Re: Text input mode and user input validation

On the Qt/qml side we can use inputMethodHints: to show the keys you want on the vkb, there is also a validator: for the input. I would assume that its the same with cascades, but I am only assuming.

Here is an example right out of one of my qml apps:

		TextField
		{
		    id: texfFLA
                    font.pointSize: 14
		    x: parent.width * .2
		    width: parent.width - x - 10
		    text: "10"
                    errorHighlight: false
                    validator: DoubleValidator {top: 12; decimals: 4;}
                    inputMethodHints: Qt.ImhFormattedNumbersOnly
                }

 See here for further documentation.

 

Hope that helps!

Jon

Please use plain text.
Developer
discnick
Posts: 17
Registered: ‎05-30-2012
My Device: Blackberry 10 Alpha Device
My Carrier: Cosmote

Re: Text input mode and user input validation


jheron wrote:

On the Qt/qml side we can use inputMethodHints: to show the keys you want on the vkb, there is also a validator: for the input. I would assume that its the same with cascades, but I am only assuming.

Here is an example right out of one of my qml apps:

		TextField
		{
		    id: texfFLA
                    font.pointSize: 14
		    x: parent.width * .2
		    width: parent.width - x - 10
		    text: "10"
                    errorHighlight: false
                    validator: DoubleValidator {top: 12; decimals: 4;}
                    inputMethodHints: Qt.ImhFormattedNumbersOnly
                }

 See here for further documentation.

 

Hope that helps!

Jon


 

No there is not a property such as validator , neither one such as inputMethodHints. There is a property named inputMode , which doesn't seem to be working..
Please use plain text.
BlackBerry Development Advisor (Retired)
amarcon
Posts: 155
Registered: ‎07-16-2012
My Device: Dev Alpha
My Carrier: Bell

Re: Text input mode and user input validation

Hi,

 

I was about to suggest to raise an issue for it, glad you did it already.

 

About the keyboard, you can notice some difference on the field itself, I mean, if you set the inputMode as TextFieldInputMode.EmailAddress, the first letter won't be capitalized or even if you set TextFieldInputMode.Chat, you will notice a new line on the top of the keyboard with some correction/suggestion texts.

Please use plain text.
Developer
Suns33k3r
Posts: 26
Registered: ‎07-22-2012
My Device: Z10
My Carrier: Telstra

Re: Text input mode and user input validation

Thanks for these hints.

 

Though, I think that's not enough for input validation. So situation right now is such as if I want to implement validation I have to call C++ code from one of the TextField signals, implement user input parsing in that C++ function by myself and then do something with GUI (raise a pop-up dialog or change state of some widgets etc) directly from it. That doesn't look as a handy method of doing that sort of things.

 

Hope this issue will be resolved soon. Guys, please vote up for an issue in the Issue Tracker so the more votes it gets the more attention it will be paid and as a result resolved sooner.

Please use plain text.
BlackBerry Development Advisor (Retired)
amarcon
Posts: 155
Registered: ‎07-16-2012
My Device: Dev Alpha
My Carrier: Bell

Re: Text input mode and user input validation

Hello,

 

I've updated the issue to make it Public, so if you tried voting, please try again.

 

Cheers,

Please use plain text.
Contributor
mariomunera89
Posts: 15
Registered: ‎10-10-2012
My Device: Blackberry 10 Dev Alpha
My Carrier: N/A

Re: Text input mode and user input validation

Does anybody finally found a way to make an input validation in real time? E.g: A TextField that doesn't allowed any input characters but numbers and dots? 

Please use plain text.
Developer
Suns33k3r
Posts: 26
Registered: ‎07-22-2012
My Device: Z10
My Carrier: Telstra

Re: Text input mode and user input validation

Yep, that guy did it via textChanging() signal and a regex.

Check this post out - http://supportforums.blackberry.com/t5/Cascades-Development/Preventing-non-numeric-key-presses-in-a-...

Please use plain text.