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

Web and WebWorks Development

Reply
Developer
Levion
Posts: 137
Registered: ‎12-22-2010
My Device: Curve 8520

First letter always capital while textinput

Hi,

 

is there a easy way to suggest a capital letter while textinput? I have seen this in native android apps and love it. It's very usefull to input names, locations, ...

 

best regards

 

Levion

Developer
interfaSys
Posts: 817
Registered: ‎11-19-2009
My Device: Z10, Q10, 9900, 9790, PlayBook,

Re: First letter always capital while textinput

You mean so that each word starts with a capital letter?
--
Olivier - interfaSys ltd
Developing for BlackBerry 10 devices using the Sencha Touch framework.
Developer
interfaSys
Posts: 817
Registered: ‎11-19-2009
My Device: Z10, Q10, 9900, 9790, PlayBook,

Re: First letter always capital while textinput

In your CSS, add this to your input class:
text-transform: capitalize;
--
Olivier - interfaSys ltd
Developing for BlackBerry 10 devices using the Sencha Touch framework.
Developer
Levion
Posts: 137
Registered: ‎12-22-2010
My Device: Curve 8520

Re: First letter always capital while textinput

That's it :smileyhappy: thx

New Contributor
phdesign
Posts: 8
Registered: ‎12-16-2012
My Device: PlayBook

Re: First letter always capital while textinput

This forces every word to start with an uppercase and the user can't change it. Is there a way to replicate the native functionality where the keyboard is in captial mode for the first letter only and by pushing shift the user can change it to lower case?

Developer
Levion
Posts: 137
Registered: ‎12-22-2010
My Device: Curve 8520

Re: First letter always capital while textinput

I am also interested, because I found a problem with this solution. The first letter is capital displayed but isn't saved like that (it's logical because only CSS redesigns it, I didn't see it). In addition the CSS solution does not work on some android devices.

 

Any other ideas?

Retired
mimendoza
Posts: 64
Registered: ‎06-04-2012
My Device: Blackberry Z10

Re: First letter always capital while textinput

[ Edited ]

In addition to using CSS for the display of the text, you can use the toUpperCase() method prior to saving the data.

eg: var text2 = text1.charAt(0).toUpperCase() + text1.slice(1);

http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript

----------------------------------------------------------------------------------
- Did this post help solve the issue? Click on "Accept as Solution"
- Was the content of this post helpful? Please give it a "Thumbs Up"

developer.blackberry.com
@BlackBerryDev
New Contributor
phdesign
Posts: 8
Registered: ‎12-16-2012
My Device: PlayBook

Re: First letter always capital while textinput

Thanks mimendoza. Unfortunately this still enforces the capitalization on the user, I was hoping there was an API call to put the keyboard in a different mode, maybe we need to build this as a plugin.
BlackBerry Development Advisor
twindsor
Posts: 832
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: First letter always capital while textinput

I don't think a plugin/extension is the right way to go here - unless you mean as a reusable component that could be dropped into web projects and attached to text fields. We don't need native code to do this, but something for HTML5 would be good.

 

What about attaching an oninput function to the text field, and capitalizing the first letter for the user. If the letter has already been changed to be capitalized once, then don't change it - so you cover the use case of deleting the capitalized letter and replacing it with a small one? Make it cut out if there's more than one character in it?

Tim Windsor
Open Source Technical Lead
Developer
interfaSys
Posts: 817
Registered: ‎11-19-2009
My Device: Z10, Q10, 9900, 9790, PlayBook,

Re: First letter always capital while textinput

[ Edited ]

I think Tim is right, the right approach is to visually do the changes and not to do it before saving as the user may not be pleased with the result.

There are some corner cases which may annoy users as well. For acronyms per example. If I type CP 1234 for the address and you keep changing it to Cp 1234, that might annoy me.

--
Olivier - interfaSys ltd
Developing for BlackBerry 10 devices using the Sencha Touch framework.