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
Posts: 185
Registered: ‎08-17-2008
My Device: Red BlackBerry Z10
My Carrier: Vodafone

Widget: only accept numbers in a Textbox?

Hi,

 

I have a TextBox in a .html Widget page and I wants to accept only number in this TextBox field.

 

Works fime in the BlackBerry Browser with something like 

 

.format_15n {-wap-input-format: "NNNNNNNNNNNNNNN"; -wap-input-required: false;} 

 

But if I access to this webpage via a Widget the Number format don't works.

 

Somebody knows how is the method, property or .... for do this in a TextBox in a Widget? 

 

Thanks in advance

 

 

Josep Maria
Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Widget: only accept numbers in a Textbox?

From your post it looks like you are using some WAP formats.   Have you tried the following as a common way used in HTML for limiting number only input.

 

http://www.htmlcodetutorial.com/forms/index_famsupp_158.html

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Developer
Posts: 185
Registered: ‎08-17-2008
My Device: Red BlackBerry Z10
My Carrier: Vodafone

Re: Widget: only accept numbers in a Textbox?

Hi Tim thanks for your response,

 

just tested and i have the same problem with the widget TextBox Smiley Sad

 

on Chome Browser work fine, only accepts numbers, but on the Widget accepts letters and numbers

 

Josep Maria
Developer
Posts: 87
Registered: ‎02-26-2010
My Device: Bold 9000
My Carrier: Rogers

Re: Widget: only accept numbers in a Textbox?

I don't know if this will work, but have you tried using Javascript with REGEX?

 

Just have a function such as validateInput() that will be called onChange of the input. And inside the function ensure the user uses numbers only ^[0-9]*$

 

Kind of naive approach but it may work.

New Developer
Posts: 24
Registered: ‎01-20-2010
My Device: Storm2
My Carrier: Vodafone Greece

Re: Widget: only accept numbers in a Textbox?

Where can we find the "keyCode" for all keys of the device so that we can write a small function to handle this kind of situations?

Developer
Posts: 185
Registered: ‎08-17-2008
My Device: Red BlackBerry Z10
My Carrier: Vodafone

Re: Widget: only accept numbers in a Textbox?

[ Edited ]

After spending some time and did it some test, i think it's impossible to do a Numeric TextBox in a Widget Smiley Sad

 

The best solution in the BlackBerry Browser it's with Wap format, because appears directly the numeric keyboard and no accept letters.

 

Very weird that we don't have a simple solution for this in Widget development ¿?

 

So if somebody have a solution like the Browser WAP format for Widgets are welcome.

Josep Maria
Developer
Posts: 482
Registered: ‎10-24-2008
My Device: 9300
My Carrier: AT&T

Re: Widget: only accept numbers in a Textbox?

I've used the wap input format in my widgets. Seems to work out.

_________________________________________
www.jasonmace.com/blackberry
New Developer
Posts: 24
Registered: ‎01-20-2010
My Device: Storm2
My Carrier: Vodafone Greece

Re: Widget: only accept numbers in a Textbox?

Can you please give us an example of how you've got it working !

Developer
Posts: 482
Registered: ‎10-24-2008
My Device: 9300
My Carrier: AT&T

Re: Widget: only accept numbers in a Textbox?

<input type="text" style='-wap-input-format: "*N";' />

 

 

pretty simple. Beware, does not handle decimals...

_________________________________________
www.jasonmace.com/blackberry
New Developer
Posts: 24
Registered: ‎01-20-2010
My Device: Storm2
My Carrier: Vodafone Greece

Re: Widget: only accept numbers in a Textbox?

Actually, it is really simple ( once you figure it out ! ), but how can we make it handle decimals ?