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
jmace
Posts: 482
Registered: ‎10-24-2008
My Device: 9300
My Carrier: AT&T

Re: Widget: only accept numbers in a Textbox?

let me know when you figure that one out. I don't think there is an "out of the box" solution.

 

The link Tim posted above... if that code was modified to check for the decimal, it should work.

_________________________________________
www.jasonmace.com/blackberry
Please use plain text.
Developer
miamon
Posts: 180
Registered: ‎08-17-2008
My Device: Red BlackBerry Z10
My Carrier: Vodafone

Re: Widget: only accept numbers in a Textbox?

jmace: just tested in other simulator (8530 v5.0.0.337) and works :smileyhappy: 

 

Patheo: try with something like: "NN\.NN"

Josep Maria
Please use plain text.
New Developer
PaTheo
Posts: 24
Registered: ‎01-20-2010
My Device: Storm2
My Carrier: Vodafone Greece

Re: Widget: only accept numbers in a Textbox?

Unfortunately, jmace was correct, it is difficult (not to say impossible) to handle decimals.

Miamon, i tried your suggestion but it does not work.

Other tests I made were with: "*N\.2N" and with two backslashes (\\) as escape character but nothing seems to work.

Please use plain text.
Developer
jmace
Posts: 482
Registered: ‎10-24-2008
My Device: 9300
My Carrier: AT&T

Re: Widget: only accept numbers in a Textbox?

a javascript solution

_________________________________________
www.jasonmace.com/blackberry
Please use plain text.
Administrator
astanley
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Widget: only accept numbers in a Textbox?

Hi Jason,

 

Have you considered using the "inputmode" property?  This property autochanges the keyboard input mode to the selected type when the user adds focus to given input field.

 

Here's an example of how you can specify that the numeric keyboard be used when the user enters values in a text input field:

 

 

<input type="text" id="txtInput" value="" inputmode="digits" />

 

 

Note: this property won't restrict non-numeric values from being entered.  However it can be used to help make it more convenient for your end users to enter certain types of data.

 

Cheers,

Adam

    <div> <b> lowerCase </b>: <input type="text" id="txtInputA" value="" inputmode="lowerCase" /> <br/> </div>
    <div> <b> upperCase </b>: <input type="text" id="txtInputB" value="" inputmode="upperCase" /> <br/> </div>
    <div> <b> titleCase </b>: <input type="text" id="txtInputC" value="" inputmode="titleCase" /> <br/> </div>
    <div> <b> startUpper </b>: <input type="text" id="txtInputD" value="" inputmode="startUpper" /> <br/> </div>
    <div> <b> digits </b>: <input type="text" id="txtInputE" value="" inputmode="digits" /> <br/> </div>
    <div> <b> symbols </b>: <input type="text" id="txtInputF" value="" inputmode="symbols" /> <br/> </div>
    <div> <b> predictOn </b>: <input type="text" id="txtInputG" value="" inputmode="predictOn" /> <br/> </div>
    <div> <b> predictOff </b>: <input type="text" id="txtInputH" value="" inputmode="predictOff" /> <br/> </div>
Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Please use plain text.
Developer
mikeo007
Posts: 28
Registered: ‎11-17-2009
My Device: 9900
My Carrier: ATT

Re: Widget: only accept numbers in a Textbox?

Combining astanley & jmace's suggestions should provide a pretty foolproof way of implementing this function.  I was going to suggest javascript myself, but that script seems to be exactly what I had in mind.

Please use plain text.