07-29-2012 09:57 AM
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?
Solved! Go to Solution.
07-30-2012 06:46 AM
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
07-30-2012 04:30 PM
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
07-31-2012 08:08 AM
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..
07-31-2012 04:53 PM
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.
07-31-2012 07:53 PM
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.
08-08-2012 09:13 AM
Hello,
I've updated the issue to make it Public, so if you tried voting, please try again.
Cheers,
01-29-2013 02:47 PM
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?
01-29-2013 06:32 PM
Yep, that guy did it via textChanging() signal and a regex.
Check this post out - http://supportforums.blackberry.com/t5/Cascades-De